summaryrefslogtreecommitdiff
path: root/test/include
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2023-01-20 06:03:17 +0300
committerEd Tanous <ed@tanous.net>2023-02-17 06:28:23 +0300
commit50ebd4af91ece2e7b5e75b600f83a2a74b315068 (patch)
tree94f4efb8624af4cb3aac1bf71ab6f4bf0df70e37 /test/include
parent455ccdf33c4580eb9ac3e71152fa8854266b7fbc (diff)
downloadbmcweb-50ebd4af91ece2e7b5e75b600f83a2a74b315068.tar.xz
Implement alternative to on boost::split
boost::split has a documented false-positive in clang-tidy. While normally we'd handle this with NOLINTNEXTLINE, this doesn't appear to work in all cases. Unclear why, but seems to be due to some of our lambda callback complexity. Each of these uses is a case where we should be using a more specific check, rather than split, but for the moment, this is the best we have. Tested: clang-tidy passes. [1] https://github.com/llvm/llvm-project/issues/40486 Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I144c6610cb740287b7225e2be03b4142a64f9563
Diffstat (limited to 'test/include')
-rw-r--r--test/include/str_utility_test.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/include/str_utility_test.cpp b/test/include/str_utility_test.cpp
new file mode 100644
index 0000000000..bab14c96bf
--- /dev/null
+++ b/test/include/str_utility_test.cpp
@@ -0,0 +1,31 @@
+#include "str_utility.hpp"
+
+#include <string>
+#include <vector>
+
+#include <gmock/gmock.h> // IWYU pragma: keep
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
+// IWYU pragma: no_include <gmock/gmock-matchers.h>
+
+namespace
+{
+
+using ::testing::ElementsAre;
+using ::testing::IsEmpty;
+
+TEST(Split, PositiveTests)
+{
+ using bmcweb::split;
+ std::vector<std::string> vec;
+ split(vec, "xx-abc-xx-abb", '-');
+ EXPECT_THAT(vec, ElementsAre("xx", "abc", "xx", "abb"));
+ vec.clear();
+ split(vec, "", '-');
+ EXPECT_THAT(vec, IsEmpty());
+}
+
+} // namespace