mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-16 04:32:33 +00:00
26 lines
1.0 KiB
C++
26 lines
1.0 KiB
C++
|
#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);
|
||
|
}
|