Skip to content

Commit 7a19194

Browse files
authored
[NFC][ADT] Add unit test for llvm::mismatch. (#105459)
- Add basic unit test for llvm::mismatch.
1 parent a80dd44 commit 7a19194

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

llvm/unittests/ADT/STLExtrasTest.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,33 @@ TEST(STLExtrasTest, LessSecond) {
13491349
}
13501350
}
13511351

1352+
TEST(STLExtrasTest, Mismatch) {
1353+
{
1354+
const int MMIndex = 5;
1355+
StringRef First = "FooBar";
1356+
StringRef Second = "FooBaz";
1357+
auto [MMFirst, MMSecond] = mismatch(First, Second);
1358+
EXPECT_EQ(MMFirst, First.begin() + MMIndex);
1359+
EXPECT_EQ(MMSecond, Second.begin() + MMIndex);
1360+
}
1361+
1362+
{
1363+
SmallVector<int> First = {0, 1, 2};
1364+
SmallVector<int> Second = {0, 1, 2, 3};
1365+
auto [MMFirst, MMSecond] = mismatch(First, Second);
1366+
EXPECT_EQ(MMFirst, First.end());
1367+
EXPECT_EQ(MMSecond, Second.begin() + 3);
1368+
}
1369+
1370+
{
1371+
SmallVector<int> First = {0, 1};
1372+
SmallVector<int> Empty;
1373+
auto [MMFirst, MMEmpty] = mismatch(First, Empty);
1374+
EXPECT_EQ(MMFirst, First.begin());
1375+
EXPECT_EQ(MMEmpty, Empty.begin());
1376+
}
1377+
}
1378+
13521379
struct Foo;
13531380
struct Bar {};
13541381

0 commit comments

Comments
 (0)