1#include <string>
2#include <common/find_symbols.h>
3#include <gtest/gtest.h>
4
5
6TEST(find_symbols, SimpleTest)
7{
8 std::string s = "Hello, world! Goodbye...";
9 const char * begin = s.data();
10 const char * end = s.data() + s.size();
11
12 ASSERT_EQ(find_first_symbols<'a'>(begin, end), end);
13 ASSERT_EQ(find_first_symbols<'e'>(begin, end), begin + 1);
14 ASSERT_EQ(find_first_symbols<'.'>(begin, end), begin + 21);
15 ASSERT_EQ(find_first_symbols<' '>(begin, end), begin + 6);
16 ASSERT_EQ(find_first_symbols<'H'>(begin, end), begin);
17 ASSERT_EQ((find_first_symbols<'a', 'e'>(begin, end)), begin + 1);
18
19 ASSERT_EQ(find_last_symbols_or_null<'a'>(begin, end), nullptr);
20 ASSERT_EQ(find_last_symbols_or_null<'e'>(begin, end), end - 4);
21 ASSERT_EQ(find_last_symbols_or_null<'.'>(begin, end), end - 1);
22 ASSERT_EQ(find_last_symbols_or_null<' '>(begin, end), end - 11);
23 ASSERT_EQ(find_last_symbols_or_null<'H'>(begin, end), begin);
24 ASSERT_EQ((find_last_symbols_or_null<'a', 'e'>(begin, end)), end - 4);
25}
26