1
/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
17
#include <my_global.h>
22
Test that like_range() returns well-formed results.
25
test_like_range_for_charset(CHARSET_INFO *cs, const char *src, size_t src_len)
27
char min_str[32], max_str[32];
28
size_t min_len, max_len, min_well_formed_len, max_well_formed_len;
31
cs->coll->like_range(cs, src, src_len, '\\', '_', '%',
32
sizeof(min_str), min_str, max_str, &min_len, &max_len);
33
diag("min_len=%d\tmax_len=%d\t%s", (int) min_len, (int) max_len, cs->name);
34
min_well_formed_len= cs->cset->well_formed_len(cs,
35
min_str, min_str + min_len,
37
max_well_formed_len= cs->cset->well_formed_len(cs,
38
max_str, max_str + max_len,
40
if (min_len != min_well_formed_len)
41
diag("Bad min_str: min_well_formed_len=%d min_str[%d]=0x%02X",
42
(int) min_well_formed_len, (int) min_well_formed_len,
43
(uchar) min_str[min_well_formed_len]);
44
if (max_len != max_well_formed_len)
45
diag("Bad max_str: max_well_formed_len=%d max_str[%d]=0x%02X",
46
(int) max_well_formed_len, (int) max_well_formed_len,
47
(uchar) max_str[max_well_formed_len]);
49
min_len == min_well_formed_len &&
50
max_len == max_well_formed_len ? 0 : 1;
54
static CHARSET_INFO *charset_list[]=
56
#ifdef HAVE_CHARSET_big5
57
&my_charset_big5_chinese_ci,
60
#ifdef HAVE_CHARSET_euckr
61
&my_charset_euckr_korean_ci,
62
&my_charset_euckr_bin,
64
#ifdef HAVE_CHARSET_gb2312
65
&my_charset_gb2312_chinese_ci,
66
&my_charset_gb2312_bin,
68
#ifdef HAVE_CHARSET_gbk
69
&my_charset_gbk_chinese_ci,
72
#ifdef HAVE_CHARSET_latin1
74
&my_charset_latin1_bin,
76
#ifdef HAVE_CHARSET_sjis
77
&my_charset_sjis_japanese_ci,
80
#ifdef HAVE_CHARSET_tis620
81
&my_charset_tis620_thai_ci,
82
&my_charset_tis620_bin,
84
#ifdef HAVE_CHARSET_ujis
85
&my_charset_ujis_japanese_ci,
88
#ifdef HAVE_CHARSET_utf8
89
&my_charset_utf8_general_ci,
90
&my_charset_utf8_unicode_ci,
101
diag("Testing my_like_range_xxx() functions");
103
for (i= 0; i < array_elements(charset_list); i++)
105
CHARSET_INFO *cs= charset_list[i];
106
if (test_like_range_for_charset(cs, "abc%", 4))
109
diag("Failed for %s", cs->name);
112
ok(failed == 0, "Testing my_like_range_xxx() functions");
113
return exit_status();