17 #include "my_config.h"
18 #include <gtest/gtest.h>
20 #include <my_global.h>
23 namespace like_range_unittest {
29 test_like_range_for_charset(
CHARSET_INFO *cs,
const char *src,
size_t src_len)
31 char min_str[32], max_str[32];
32 size_t min_len, max_len, min_well_formed_len, max_well_formed_len;
35 cs->coll->like_range(cs, src, src_len,
'\\',
'_',
'%',
36 sizeof(min_str), min_str, max_str, &min_len, &max_len);
38 min_well_formed_len= cs->cset->well_formed_len(cs,
39 min_str, min_str + min_len,
41 max_well_formed_len= cs->cset->well_formed_len(cs,
42 max_str, max_str + max_len,
44 EXPECT_EQ(min_len, min_well_formed_len)
45 <<
"Bad min_str: min_well_formed_len=" << min_well_formed_len
46 <<
" min_str[" << min_well_formed_len <<
"]="
47 << (uchar) min_str[min_well_formed_len];
48 EXPECT_EQ(max_len, max_well_formed_len)
49 <<
"Bad max_str: max_well_formed_len=" << max_well_formed_len
50 <<
" max_str[" << max_well_formed_len <<
"]="
51 << (uchar) max_str[max_well_formed_len];
57 #ifdef HAVE_CHARSET_big5
58 &my_charset_big5_chinese_ci,
61 #ifdef HAVE_CHARSET_euckr
62 &my_charset_euckr_korean_ci,
63 &my_charset_euckr_bin,
65 #ifdef HAVE_CHARSET_gb2312
66 &my_charset_gb2312_chinese_ci,
67 &my_charset_gb2312_bin,
69 #ifdef HAVE_CHARSET_gbk
70 &my_charset_gbk_chinese_ci,
73 #ifdef HAVE_CHARSET_latin1
75 &my_charset_latin1_bin,
77 #ifdef HAVE_CHARSET_sjis
78 &my_charset_sjis_japanese_ci,
81 #ifdef HAVE_CHARSET_tis620
82 &my_charset_tis620_thai_ci,
83 &my_charset_tis620_bin,
85 #ifdef HAVE_CHARSET_ujis
86 &my_charset_ujis_japanese_ci,
89 #ifdef HAVE_CHARSET_utf8
90 &my_charset_utf8_general_ci,
91 &my_charset_utf8_unicode_ci,
96 #if defined(GTEST_HAS_PARAM_TEST)
98 class LikeRangeTest :
public ::testing::TestWithParam<CHARSET_INFO*>
103 m_charset= GetParam();
108 INSTANTIATE_TEST_CASE_P(Foo1, LikeRangeTest,
109 ::testing::ValuesIn(charset_list));
112 TEST_P(LikeRangeTest, TestLikeRange)
114 test_like_range_for_charset(m_charset,
"abc%", 4);