[llvm] [NFC][ADT] Add unit tests for llvm::maximal. (PR #105459)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 20 18:20:31 PDT 2024
https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/105459
- Add basic unit test for llvm::maximal.
>From 4f22c770a8eb5be73358e421490953cb182d41ba Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Tue, 20 Aug 2024 18:18:46 -0700
Subject: [PATCH] [NFC][ADT] Add unit tests for llvm::maximal.
- Add basic unit test for llvm::maximal.
---
llvm/unittests/ADT/STLExtrasTest.cpp | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/llvm/unittests/ADT/STLExtrasTest.cpp b/llvm/unittests/ADT/STLExtrasTest.cpp
index 3927bc59c031a3..b7dc15bf60af51 100644
--- a/llvm/unittests/ADT/STLExtrasTest.cpp
+++ b/llvm/unittests/ADT/STLExtrasTest.cpp
@@ -1349,6 +1349,33 @@ TEST(STLExtrasTest, LessSecond) {
}
}
+TEST(STLExtrasTest, Mismatch) {
+ {
+ const int MMIndex = 5;
+ StringRef First = "FooBar";
+ StringRef Second = "FooBaz";
+ auto [MMFirst, MMSecond] = mismatch(First, Second);
+ EXPECT_EQ(MMFirst, First.begin() + MMIndex);
+ EXPECT_EQ(MMSecond, Second.begin() + MMIndex);
+ }
+
+ {
+ SmallVector<int> First = {0, 1, 2};
+ SmallVector<int> Second = {0, 1, 2, 3};
+ auto [MMFirst, MMSecond] = mismatch(First, Second);
+ EXPECT_EQ(MMFirst, First.end());
+ EXPECT_EQ(MMSecond, Second.begin() + 3);
+ }
+
+ {
+ SmallVector<int> First = {0, 1};
+ SmallVector<int> Empty;
+ auto [MMFirst, MMEmpty] = mismatch(First, Empty);
+ EXPECT_EQ(MMFirst, First.begin());
+ EXPECT_EQ(MMEmpty, Empty.begin());
+ }
+}
+
struct Foo;
struct Bar {};
More information about the llvm-commits
mailing list