test_addrs_LDADD = libglobal.la -lpthread -lm ${UNITTEST_LDADD} $(CRYPTO_LIBS) $(EXTRALIBS)
bin_DEBUGPROGRAMS += test_addrs
+test_str_list_SOURCES = test/test_str_list.cc
+test_str_list_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
+test_str_list_LDADD = libglobal.la -lpthread -lm ${UNITTEST_LDADD} $(CRYPTO_LIBS) $(EXTRALIBS)
+bin_DEBUGPROGRAMS += test_str_list
+
test_mutate_SOURCES = test/test_mutate.cc
test_mutate_LDADD = libglobal.la librados.la -lpthread -lm $(CRYPTO_LIBS) $(EXTRALIBS)
bin_DEBUGPROGRAMS += test_mutate
--- /dev/null
+
+#include "include/types.h"
+#include "include/str_list.h"
+
+#include <list>
+#include <string>
+
+#include "gtest/gtest.h"
+
+
+const char *tests[][10] = {
+ { "foo,bar", "foo", "bar", 0 },
+ { "foo", "foo", 0 },
+ { "foo;bar", "foo", "bar", 0 },
+ { "foo bar", "foo", "bar", 0 },
+ { " foo bar", "foo", "bar", 0 },
+ { " foo bar ", "foo", "bar", 0 },
+ { "a,b,c", "a", "b", "c", 0 },
+ { " a\tb\tc\t", "a", "b", "c", 0 },
+ { 0 },
+};
+
+TEST(StrList, All)
+{
+ for (unsigned i=0; tests[i][0]; ++i) {
+ std::string src = tests[i][0];
+ std::list<std::string> expected;
+ for (unsigned j=1; tests[i][j]; ++j)
+ expected.push_back(tests[i][j]);
+ std::list<std::string> actual;
+ get_str_list(src, actual);
+ std::cout << "'" << src << "' -> " << actual << std::endl;
+ ASSERT_EQ(actual, expected);
+ }
+}