ClickHouse/base/common/tests/gtest_find_symbols.cpp

26 lines
1.0 KiB
C++
Raw Normal View History

#include <string>
#include <common/find_symbols.h>
#include <gtest/gtest.h>
TEST(find_symbols, 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);
}