mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-16 12:44:42 +00:00
39 lines
1.4 KiB
C++
39 lines
1.4 KiB
C++
#include <string>
|
|
#include <vector>
|
|
#include <common/find_symbols.h>
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
TEST(FindSymbols, SimpleTest)
|
|
{
|
|
std::string s = "Hello, world! Goodbye...";
|
|
const char * begin = s.data();
|
|
const char * end = s.data() + s.size();
|
|
|
|
ASSERT_EQ(find_first_symbols<'a'>(begin, end), end);
|
|
ASSERT_EQ(find_first_symbols<'e'>(begin, end), begin + 1);
|
|
ASSERT_EQ(find_first_symbols<'.'>(begin, end), begin + 21);
|
|
ASSERT_EQ(find_first_symbols<' '>(begin, end), begin + 6);
|
|
ASSERT_EQ(find_first_symbols<'H'>(begin, end), begin);
|
|
ASSERT_EQ((find_first_symbols<'a', 'e'>(begin, end)), begin + 1);
|
|
|
|
ASSERT_EQ(find_last_symbols_or_null<'a'>(begin, end), nullptr);
|
|
ASSERT_EQ(find_last_symbols_or_null<'e'>(begin, end), end - 4);
|
|
ASSERT_EQ(find_last_symbols_or_null<'.'>(begin, end), end - 1);
|
|
ASSERT_EQ(find_last_symbols_or_null<' '>(begin, end), end - 11);
|
|
ASSERT_EQ(find_last_symbols_or_null<'H'>(begin, end), begin);
|
|
ASSERT_EQ((find_last_symbols_or_null<'a', 'e'>(begin, end)), end - 4);
|
|
|
|
{
|
|
std::vector<std::string> vals;
|
|
splitInto<' ', ','>(vals, "hello, world", true);
|
|
ASSERT_EQ(vals, (std::vector<std::string>{"hello", "world"}));
|
|
}
|
|
|
|
{
|
|
std::vector<std::string> vals;
|
|
splitInto<' ', ','>(vals, "s String", true);
|
|
ASSERT_EQ(vals, (std::vector<std::string>{"s", "String"}));
|
|
}
|
|
}
|