|
11 | 11 | //===----------------------------------------------------------------------===// |
12 | 12 |
|
13 | 13 | #include "swift/IDE/FuzzyStringMatcher.h" |
| 14 | +#include "swift/Basic/Compiler.h" |
14 | 15 | #include "gtest/gtest.h" |
15 | 16 |
|
16 | 17 | using FuzzyStringMatcher = swift::ide::FuzzyStringMatcher; |
@@ -53,26 +54,31 @@ TEST(FuzzyStringMatcher, SingleCharacterMatching) { |
53 | 54 |
|
54 | 55 | TEST(FuzzyStringMatcher, UnicodeMatching) { |
55 | 56 | // Single code point matching. |
56 | | - EXPECT_TRUE(FuzzyStringMatcher(u8"\u2602a\U0002000Bz") |
57 | | - .matchesCandidate(u8"\u2602A\U0002000BZ")); |
| 57 | + EXPECT_TRUE(FuzzyStringMatcher(SWIFT_UTF8("\u2602a\U0002000Bz")) |
| 58 | + .matchesCandidate(SWIFT_UTF8("\u2602A\U0002000BZ"))); |
58 | 59 |
|
59 | 60 | // Same-order combining marks. |
60 | | - EXPECT_TRUE(FuzzyStringMatcher(u8"a\u0323\u0307") |
61 | | - .matchesCandidate(u8"A\u0323\u0307")); |
| 61 | + EXPECT_TRUE(FuzzyStringMatcher(SWIFT_UTF8("a\u0323\u0307")) |
| 62 | + .matchesCandidate(SWIFT_UTF8("A\u0323\u0307"))); |
62 | 63 |
|
63 | 64 | // FIXME: Canonical equivalence. These should be the same. |
64 | | - EXPECT_FALSE(FuzzyStringMatcher(u8"a\u0307\u0323") |
65 | | - .matchesCandidate(u8"A\u0323\u0307")); |
66 | | - EXPECT_FALSE(FuzzyStringMatcher(u8"a\u00C5").matchesCandidate(u8"A\u030A")); |
| 65 | + EXPECT_FALSE(FuzzyStringMatcher(SWIFT_UTF8("a\u0307\u0323")) |
| 66 | + .matchesCandidate(SWIFT_UTF8("A\u0323\u0307"))); |
| 67 | + EXPECT_FALSE(FuzzyStringMatcher(SWIFT_UTF8("a\u00C5")) |
| 68 | + .matchesCandidate(SWIFT_UTF8("A\u030A"))); |
67 | 69 |
|
68 | 70 | // FIXME: Compatibility equivalence. It would be good to make these the same |
69 | 71 | // too, since we're fuzzy matching. |
70 | | - EXPECT_FALSE(FuzzyStringMatcher(u8"fi").matchesCandidate(u8"\uFB01")); |
71 | | - EXPECT_FALSE(FuzzyStringMatcher(u8"25").matchesCandidate(u8"2\u2075")); |
| 72 | + EXPECT_FALSE(FuzzyStringMatcher(SWIFT_UTF8("fi")) |
| 73 | + .matchesCandidate(SWIFT_UTF8("\uFB01"))); |
| 74 | + EXPECT_FALSE(FuzzyStringMatcher(SWIFT_UTF8("25")) |
| 75 | + .matchesCandidate(SWIFT_UTF8("2\u2075"))); |
72 | 76 |
|
73 | 77 | // FIXME: Case-insensitivity in non-ASCII characters. |
74 | | - EXPECT_FALSE(FuzzyStringMatcher(u8"\u00E0").matchesCandidate(u8"\u00C0")); |
75 | | - EXPECT_FALSE(FuzzyStringMatcher(u8"ss").matchesCandidate(u8"\u00DF")); |
| 78 | + EXPECT_FALSE(FuzzyStringMatcher(SWIFT_UTF8("\u00E0")) |
| 79 | + .matchesCandidate(SWIFT_UTF8("\u00C0"))); |
| 80 | + EXPECT_FALSE(FuzzyStringMatcher(SWIFT_UTF8("ss")) |
| 81 | + .matchesCandidate(SWIFT_UTF8("\u00DF"))); |
76 | 82 | } |
77 | 83 |
|
78 | 84 | TEST(FuzzyStringMatcher, BasicScoring) { |
|
0 commit comments