#include <my_global.h>#include <stdarg.h>#include "m_string.h"Include dependency graph for str_test.c:

Go to the source code of this file.
Defines | |
| #define | F_LEN 8 |
| #define | F_CHAR 'A' |
| #define | F_FILL 'B' |
| #define | T_LEN 15 |
| #define | T_CHAR 'D' |
| #define | T_FILL 'E' |
| #define | F_PREFILL '0' |
| #define | T_PREFILL '1' |
Functions | |
| static int | test_strarg (const char *name,...) |
| static void | init_strings (void) |
| void | test_arg (const char *message, long func_value, long value) |
| int | compare_buff (const char *message, my_string b1, my_string b2, int length, pchar fill, pchar prefill) |
| static int | my_test (int a) |
| int | main (void) |
| void | test_arg (const char *message, long int func_value, long int value) |
| void | dummy_functions (void) |
Variables | |
| static char | from_buff [100] |
| static char | to_buff [100] |
| static my_string | from |
| static my_string | to |
| static int | errors |
| static int | tests |
| #define F_CHAR 'A' |
| #define F_FILL 'B' |
| #define F_LEN 8 |
| #define F_PREFILL '0' |
| #define T_CHAR 'D' |
| #define T_FILL 'E' |
| #define T_LEN 15 |
| #define T_PREFILL '1' |
| int compare_buff | ( | const char * | message, | |
| my_string | b1, | |||
| my_string | b2, | |||
| int | length, | |||
| pchar | fill, | |||
| pchar | prefill | |||
| ) |
Definition at line 232 of file str_test.c.
Referenced by test_strarg().
00234 { 00235 int i,error=0; 00236 00237 if (bcmp(b1,b2,length)) 00238 { 00239 errors++; 00240 printf("func: '%s' Buffers differ\nIs: ",message); 00241 for (i=0 ; i<length ; i++) 00242 printf("%3d ",b1[i]); 00243 printf("\nShould be: "); 00244 for (i=0 ; i<length ; i++) 00245 printf("%3d ",b2[i]); 00246 puts(""); 00247 } 00248 else if (b1[-1] != prefill || b1[-2] != fill || b1[-3] != fill) 00249 { 00250 printf("func: '%s' Chars before buffer is changed\n",message); 00251 errors++; 00252 error=1; 00253 } 00254 else if (b1[length] != fill || b1[length+1] != fill) 00255 { 00256 printf("func: '%s' Chars after buffer is changed\n",message); 00257 errors++; 00258 error=1; 00259 } 00260 return error; 00261 } /* compare_buff */
Here is the caller graph for this function:

| void dummy_functions | ( | void | ) |
Definition at line 267 of file str_test.c.
References from, memcmp(), memcpy, memset, strcmp(), strrchr(), strstr(), to, and VOID.
00268 { 00269 VOID(memchr(from,'a',5)); 00270 VOID(memcmp(from,to,5)); 00271 VOID(memcpy(from,to,5)); 00272 VOID(memset(from,' ',5)); 00273 VOID(strcmp(from,to)); 00274 VOID(strcpy(from,to)); 00275 VOID(strstr(from,to)); 00276 VOID(strrchr(from,'a')); 00277 return; 00278 }
Here is the call graph for this function:

| void init_strings | ( | void | ) | [static] |
Definition at line 140 of file str_test.c.
References F_CHAR, F_FILL, F_LEN, F_PREFILL, from, from_buff, pos(), reg1, reg2, T_CHAR, T_FILL, T_LEN, T_PREFILL, to, and to_buff.
Referenced by main(), and test_strarg().
00141 { 00142 reg1 int i; 00143 reg2 char *pos; 00144 00145 from=from_buff+3; to=to_buff+3; 00146 00147 pos=from_buff; *pos++= F_FILL; *pos++=F_FILL; *pos++=F_PREFILL; 00148 for (i=0 ; i < F_LEN ; i++) 00149 *pos++=F_CHAR; 00150 *pos++=0; 00151 for (i=0; i<50 ; i++) 00152 *pos++= F_FILL; 00153 00154 pos=to_buff; *pos++= T_FILL; *pos++=T_FILL; *pos++=T_PREFILL; 00155 for (i=0 ; i < T_LEN ; i++) 00156 *pos++=T_CHAR; 00157 *pos++=0; 00158 for (i=0; i<50 ; i++) 00159 *pos++= T_FILL; 00160 } /* init_strings */
Here is the call graph for this function:

Here is the caller graph for this function:

| int main | ( | void | ) |
Definition at line 46 of file str_test.c.
References bchange(), bcmp, bfill, bmove(), bmove_align, bmove_upp(), bzero, F_CHAR, F_LEN, from, init_strings(), INT_MAX32, is_prefix(), my_test(), NullS, strappend(), strcat(), strchr(), strcont(), strend(), strfill(), strinstr(), strlen(), strmake(), strmov(), strnlen(), strnmov(), strstr(), strxmov(), strxnmov(), T_CHAR, T_LEN, test_arg(), test_strarg(), tests, and to.
00047 { 00048 static char v1[]="Monty",v2[]="on",v3[]="Montys",v4[]="ty",v5[]="gr", 00049 v6[]="hohohoo",v7[]="hohoo",v8[]="hohooo",v9[]="t", 00050 cont[]="qwet"; 00051 errors=tests=0; 00052 init_strings(); 00053 00054 test_arg("bcmp(from,to,5)",(long) my_test(bcmp(from,to,5)),1L); 00055 test_arg("bcmp(from,from,5)",(long) bcmp(from,from,5),0L); 00056 00057 test_arg("bcmp(from,to,0)",(long) bcmp(from,to,0),0L); 00058 test_arg("strend(from)",(long) strend(from),(long) from+F_LEN); 00059 test_arg("strchr(v1,'M')",(long) strchr(v1,'M'),(long) v1); 00060 test_arg("strchr(v1,'y')",(long) strchr(v1,'y'),(long) v1+4); 00061 test_arg("strchr(v1,'x')",(long) strchr(v1,'x'),0L); 00062 test_arg("strcont(v1,cont)",(long) strcont(v1,cont),(long) v1+3); 00063 test_arg("strcont(v1,v2)",(long) strcont(v1,v2),(long) v1+1); 00064 test_arg("strcont(v1,v5)",(long) strcont(v1,v5),0L); 00065 test_arg("is_prefix(v3,v1)",(long) is_prefix(v3,v1),1L); 00066 test_arg("is_prefix(v1,v3)",(long) is_prefix(v1,v3),0L); 00067 test_arg("is_prefix(v3,v4)",(long) is_prefix(v3,v4),0L); 00068 test_arg("strstr(v1,v1)",(long) strstr(v1,v1),(long) v1); 00069 test_arg("strstr(v1,v2)",(long) strstr(v1,v2),(long) v1+1); 00070 test_arg("strstr(v1,v4)",(long) strstr(v1,v4),(long) v1+3); 00071 test_arg("strstr(v6,v7)",(long) strstr(v6,v7),(long) v6+2); 00072 test_arg("strstr(v1,v9)",(long) strstr(v1,v9),(long) v1+3); 00073 test_arg("strstr(v1,v3)",(long) strstr(v1,v3),0L); 00074 test_arg("strstr(v1,v5)",(long) strstr(v1,v5),0L); 00075 test_arg("strstr(v6,v8)",(long) strstr(v6,v8),0L); 00076 00077 test_arg("strinstr(v1,v4)",(long) strinstr(v1,v4),4L); 00078 test_arg("strinstr(v1,v5)",(long) strinstr(v1,v5),0L); 00079 test_arg("strlen(from)",(long) strlen(from),(long) F_LEN); 00080 test_arg("strlen(\"\")",(long) strlen(""),0L); 00081 #ifdef HAVE_STRNLEN 00082 test_arg("strnlen(from,3)",(long) strnlen(from,3),3L); 00083 test_arg("strnlen(from,0)",(long) strnlen(from,0),0L); 00084 test_arg("strnlen(from,1000)",(long) strnlen(from,1000),(long) F_LEN); 00085 #endif 00086 00087 test_strarg("bfill(to,4,' ')",(bfill(to,4,' '),0L),INT_MAX32,4,' ',0,0); 00088 test_strarg("bfill(from,0,' ')",(bfill(from,0,' '),0L),INT_MAX32,0,0); 00089 test_strarg("bzero(to,3)",(bzero(to,3),0L),INT_MAX32,3,0,0,0); 00090 test_strarg("bzero(to,0)",(bzero(to,0),0L),INT_MAX32,0,0); 00091 test_strarg("bmove(to,from,4)",(bmove(to,from,4),0L),INT_MAX32,4,F_CHAR, 00092 0,0); 00093 test_strarg("bmove(to,from,0)",(bmove(to,from,0),0L),INT_MAX32,0,0); 00094 test_strarg("bmove_upp(to+6,from+6,3)",(bmove_upp(to+6,from+6,3),0L),INT_MAX32, 00095 3,T_CHAR,3,F_CHAR,0,0); 00096 test_strarg("bmove_upp(to,from,0)",(bmove_upp(to,from,0),0L),INT_MAX32,0,0); 00097 test_strarg("bmove_align(to,from,8)",(bmove_align(to,from,8),0L),INT_MAX32, 00098 8,F_CHAR,0,0); 00099 test_strarg("strappend(to,3,' ')",(strappend(to,3,' '),0L),INT_MAX32, 00100 3,T_CHAR,1,0,T_LEN-4,T_CHAR,1,0,0,0); 00101 test_strarg("strappend(to,T_LEN+5,' ')",(strappend(to,T_LEN+5,' '),0L),INT_MAX32, 00102 T_LEN,T_CHAR,5,' ',1,0,0,0); 00103 test_strarg("strcat(to,from)",strcat(to,from),to,T_LEN,T_CHAR, 00104 F_LEN,F_CHAR,1,0,0,0); 00105 test_strarg("strcat(to,\"\")",strcat(to,""),INT_MAX32,0,0); 00106 test_strarg("strfill(to,4,' ')",strfill(to,4,' '),to+4,4,' ',1,0,0,0); 00107 test_strarg("strfill(from,0,' ')",strfill(from,0,' '),from,0,1,0,0); 00108 test_strarg("strmake(to,from,4)",strmake(to,from,4),to+4,4,F_CHAR, 00109 1,0,0,0); 00110 test_strarg("strmake(to,from,0)",strmake(to,from,0),to+0,1,0,0,0); 00111 test_strarg("strmov(to,from)",strmov(to,from),to+F_LEN,F_LEN,F_CHAR,0,0); 00112 test_strarg("strmov(to,\"\")",strmov(to,""),to,1,0,0,0); 00113 test_strarg("strnmov(to,from,2)",strnmov(to,from,2),to+2,2,F_CHAR,0,0); 00114 test_strarg("strnmov(to,from,F_LEN+5)",strnmov(to,from,F_LEN+5),to+F_LEN, 00115 F_LEN,F_CHAR,1,0,0,0); 00116 test_strarg("strnmov(to,\"\",2)",strnmov(to,"",2),to,1,0,0,0); 00117 test_strarg("strxmov(to,from,\"!!\",NullS)",strxmov(to,from,"!!",NullS),to+F_LEN+2,F_LEN,F_CHAR,2,'!',0,0,0); 00118 test_strarg("strxmov(to,NullS)",strxmov(to,NullS),to,1,0,0,0); 00119 test_strarg("strxmov(to,from,from,from,from,from,'!!',from,NullS)",strxmov(to,from,from,from,from,from,"!!",from,NullS),to+F_LEN*6+2,F_LEN,F_CHAR,F_LEN,F_CHAR,F_LEN,F_CHAR,F_LEN,F_CHAR,F_LEN,F_CHAR,2,'!',F_LEN,F_CHAR,1,0,0,0); 00120 00121 test_strarg("strxnmov(to,100,from,\"!!\",NullS)",strxnmov(to,100,from,"!!",NullS),to+F_LEN+2,F_LEN,F_CHAR,2,'!',0,0,0); 00122 test_strarg("strxnmov(to,2,NullS)",strxnmov(to,2,NullS),to,1,0,0,0); 00123 test_strarg("strxnmov(to,100,from,from,from,from,from,'!!',from,NullS)",strxnmov(to,100,from,from,from,from,from,"!!",from,NullS),to+F_LEN*6+2,F_LEN,F_CHAR,F_LEN,F_CHAR,F_LEN,F_CHAR,F_LEN,F_CHAR,F_LEN,F_CHAR,2,'!',F_LEN,F_CHAR,1,0,0,0); 00124 test_strarg("strxnmov(to,2,\"!!!\",NullS)",strxnmov(to,2,"!!!",NullS),to+2,2,'!',0,0,0); 00125 test_strarg("strxnmov(to,2,\"!!\",NullS)",strxnmov(to,2,"!!","xx",NullS),to+2,2,'!',0,0,0); 00126 test_strarg("strxnmov(to,2,\"!\",\"x\",\"y\",NullS)",strxnmov(to,2,"!","x","y",NullS),to+2,1,'!',1,'x',0,0,0); 00127 00128 test_strarg("bchange(to,2,from,4,6)",(bchange(to,2,from,4,6),0L),INT_MAX32, 00129 4,F_CHAR,2,T_CHAR,0,0); 00130 00131 printf("tests: %d errors: %d\n",tests,errors); 00132 if (errors) 00133 fputs("--- Some functions doesn't work!! Fix them\n",stderr); 00134 return(errors > 0); 00135 } /* main */
Here is the call graph for this function:

| static int my_test | ( | int | a | ) | [static] |
Definition at line 41 of file str_test.c.
Referenced by main().
Here is the caller graph for this function:

| void test_arg | ( | const char * | message, | |
| long int | func_value, | |||
| long int | value | |||
| ) |
| void test_arg | ( | const char * | message, | |
| long | func_value, | |||
| long | value | |||
| ) |
| static int test_strarg | ( | const char * | name, | |
| ... | ||||
| ) | [static] |
Definition at line 178 of file str_test.c.
References compare_buff(), error, F_FILL, F_LEN, F_PREFILL, from, init_strings(), int(), INT_MAX32, pos(), T_FILL, T_LEN, T_PREFILL, tests, to, and value.
Referenced by main().
00179 { 00180 long func_value,value; 00181 int error,length; 00182 char chr,cmp_buff[100],*pos,*pos2; 00183 va_list pvar; 00184 00185 tests++; 00186 va_start(pvar,message); 00187 func_value=va_arg(pvar,long); 00188 value=va_arg(pvar,long); 00189 00190 printf("testing '%s'\n",message); 00191 if (func_value != value && value != INT_MAX32) 00192 { 00193 printf("func: '%s' = %ld Should be: %ld\n",message,func_value,value); 00194 errors++; 00195 } 00196 pos= cmp_buff; 00197 while ((length = va_arg(pvar, int)) != 0) 00198 { 00199 chr= (char) (va_arg(pvar, int)); 00200 while (length--) 00201 *pos++=chr; 00202 } 00203 pos2=to+ (int)(pos-cmp_buff); 00204 while (pos <= cmp_buff+T_LEN) 00205 *pos++= *pos2++; 00206 if (compare_buff(message,to,cmp_buff,(int) (pos-cmp_buff),T_FILL,T_PREFILL)) 00207 { 00208 init_strings(); 00209 va_end(pvar); 00210 return 1; 00211 } 00212 00213 pos= cmp_buff; 00214 while ((length = va_arg(pvar, int)) != 0) 00215 { 00216 chr= (char) (va_arg(pvar, int)); 00217 while (length--) 00218 *pos++=chr; 00219 } 00220 pos2=from+ (int)(pos-cmp_buff); 00221 while (pos <= cmp_buff+F_LEN) 00222 *pos++= *pos2++; 00223 error=compare_buff(message,from,cmp_buff,(int) (pos-cmp_buff),F_FILL,F_PREFILL); 00224 init_strings(); 00225 va_end(pvar); 00226 return (error != 0); 00227 } /* test_strarg */
Here is the call graph for this function:

Here is the caller graph for this function:

int errors [static] |
Definition at line 34 of file str_test.c.
Definition at line 33 of file str_test.c.
Referenced by _history_expand_command(), _mi_get_binary_pack_key(), _mi_prefix_search(), add_diff_to_status(), add_to_status(), append_escaped(), append_query_string(), Bitmap< default_width >::Bitmap(), bitmap_copy(), bitmap_intersect(), bitmap_subtract(), bitmap_union(), bitmap_xor(), copy_bits(), copy_data_between_tables(), copy_if_not_alloced(), cs_copy_data(), decimal2bin(), decimal2double(), decimal2longlong(), decimal2string(), decimal2ulonglong(), decimal_actual_fraction(), decimal_intg(), decimal_is_zero(), decimal_round(), digits_bounds(), do_mini_left_shift(), do_mini_right_shift(), dummy_functions(), field_conv(), get_quoted_token(), get_replace(), get_replace_column(), get_string(), inflate(), inflate_fast(), inflateBack(), init_strings(), main(), make_sortkey(), mi_delete_table(), mi_rename(), my_decimal2decimal(), my_decimal_ceiling(), my_decimal_floor(), my_decimal_round(), mysql_rename_table(), or_bits(), prepare_for_repair(), remove_leading_zeroes(), replace_strings_append(), APZJobBuffer::retrieve(), APZJobBuffer::retrieveDump(), Copy_field::set(), simple_cs_copy_data(), sort_ft_buf_flush(), sort_write_record(), test_strarg(), unhex_type2(), Item_func_quote::val_str(), Item_func_unhex::val_str(), Item_func_soundex::val_str(), walk_and_copy(), and walk_and_push().
char from_buff[100] [static] |
int tests [static] |
Definition at line 34 of file str_test.c.
Definition at line 33 of file str_test.c.
Referenced by _history_expand_command(), _mi_put_key_in_record(), _mi_read_dynamic_record(), _mi_read_rnd_dynamic_record(), _mi_rec_check(), add_diff_to_status(), add_to_status(), append_query_string(), bin2decimal(), bitmap_copy(), bitmap_intersect(), bitmap_invert(), bitmap_set_above(), bitmap_subtract(), bitmap_union(), bitmap_xor(), calc_sum_of_all_status(), calc_time_from_sec(), check_scramble_323(), chk_data_link(), cli_read_rows(), copy_bits(), copy_data_between_tables(), copy_if_not_alloced(), create_sys_files(), cs_copy_data(), decimal_add(), decimal_div(), decimal_mod(), decimal_mul(), decimal_round(), decimal_shift(), decimal_sub(), do_add(), do_div_mod(), do_sub(), double2decimal(), dummy_functions(), examine_log(), field_conv(), get_errcodes(), get_field(), get_lock_data(), get_quoted_token(), get_replace(), get_replace_column(), get_string(), get_text(), init_param_array(), init_strings(), internal_str2dec(), key_unpack(), localtime_to_TIME(), longlong2decimal(), main(), max_decimal(), max_internal_decimal(), max_my_decimal(), mi_rename(), my_decimal2decimal(), my_decimal_ceiling(), my_decimal_floor(), my_decimal_round(), mysql_rename_table(), Protocol::net_store_data(), or_bits(), Field_decimal::overflow(), quote_for_like(), quote_name(), read_binary_date(), read_binary_datetime(), read_binary_time(), READ_INFO::read_field(), READ_INFO::read_fixed_length(), remove_escape(), String::replace(), replace_strings(), APZJobBuffer::retrieve(), APZJobBuffer::retrieveDump(), Item_func_sysdate_local::save_in_field(), Item_func_now::save_in_field(), Item_ref::save_in_field(), Item_field::save_in_field(), save_index(), Item_field::save_org_in_field(), Copy_field::set(), String::set(), set_param_date(), set_param_datetime(), set_param_time(), String::set_real(), simple_cs_copy_data(), Field_decimal::store(), Protocol_prep::store(), ha_example::store_lock(), ha_tina::store_lock(), ha_blackhole::store_lock(), ha_archive::store_lock(), ha_myisammrg::store_lock(), ha_myisam::store_lock(), ha_heap::store_lock(), Protocol_prep::store_long(), Protocol_prep::store_longlong(), Protocol_prep::store_null(), store_param_str(), Protocol_prep::store_short(), test_strarg(), to_unix_path(), ull2dec(), ulonglong2decimal(), unhex_type2(), Item_sum_distinct::val_decimal(), Item_func_quote::val_str(), Item_func_unhex::val_str(), Item_func_rpad::val_str(), Item_func_repeat::val_str(), Item_func_soundex::val_str(), Hybrid_type_traits_decimal::val_str(), Hybrid_type_traits::val_str(), and in_string::value_to_item().
char to_buff[100] [static] |
1.4.7

