mirror of
https://github.com/MariaDB/server.git
synced 2025-01-23 23:34:34 +01:00
555eb848f2
into mysql.com:/home/my/mysql-5.1 BitKeeper/etc/ignore: auto-union include/heap.h: Auto merged include/my_base.h: Auto merged include/mysql_com.h: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test: Auto merged mysql-test/r/binlog_stm_mix_innodb_myisam.result: Auto merged mysql-test/r/func_time.result: Auto merged mysql-test/r/ndb_index_unique.result: Auto merged mysql-test/t/func_time.test: Auto merged mysql-test/t/view_grant.test: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_berkeley.h: Auto merged mysql-test/r/view_grant.result: Auto merged sql/ha_federated.cc: Auto merged sql/ha_federated.h: Auto merged sql/ha_heap.h: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_innodb.h: Auto merged sql/ha_myisam.h: Auto merged sql/ha_myisammrg.cc: Auto merged sql/ha_ndbcluster.h: Auto merged sql/ha_partition.h: Auto merged sql/item.cc: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_strfunc.h: Auto merged sql/item_subselect.cc: Auto merged sql/item_subselect.h: Auto merged sql/log.cc: Auto merged sql/mysqld.cc: Auto merged sql/set_var.cc: Auto merged sql/sp.cc: Auto merged sql/sp_head.cc: Auto merged sql/spatial.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_bitmap.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_partition.cc: Auto merged sql/sql_plugin.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/share/errmsg.txt: Auto merged sql/sql_handler.cc: Auto merged sql/sql_view.cc: Auto merged sql/table.h: Auto merged storage/archive/ha_archive.cc: Auto merged storage/archive/ha_archive.h: Auto merged storage/example/ha_example.cc: Auto merged storage/myisam/ft_boolean_search.c: Auto merged unittest/mysys/base64-t.c: Auto merged mysql-test/r/innodb_mysql.result: manual merge mysql-test/t/innodb_mysql.test: manual merge mysql-test/valgrind.supp: manual merge sql/event.cc: manual merge sql/ha_heap.cc: manual merge sql/ha_myisam.cc: manual merge sql/ha_ndbcluster.cc: manual merge sql/ha_ndbcluster_binlog.cc: manual merge sql/ha_partition.cc: manual merge sql/handler.cc: manual merge renamed print_key_dupp_error to print_key_dup_error sql/handler.h: manual merge renamed print_key_dupp_error to print_key_dup_error sql/item.h: automatic merge sql/item_cmpfunc.cc: automatic merge sql/log_event.cc: manual merge Trivial cleanup sql/mysql_priv.h: manual merge renamed print_key_dupp_error to print_key_dup_error sql/opt_range.cc: manual merge renamed print_key_dupp_error to print_key_dup_error sql/sql_delete.cc: manual merge renamed print_key_dupp_error to print_key_dup_error sql/sql_insert.cc: manual merge renamed print_key_dupp_error to print_key_dup_error sql/sql_load.cc: manual merge renamed print_key_dupp_error to print_key_dup_error sql/sql_select.cc: manual merge renamed print_key_dupp_error to print_key_dup_error sql/sql_show.cc: manual merge renamed print_key_dupp_error to print_key_dup_error sql/sql_table.cc: manual merge renamed print_key_dupp_error to print_key_dup_error sql/sql_update.cc: manual merge renamed print_key_dupp_error to print_key_dup_error sql/table.cc: manual merge renamed print_key_dupp_error to print_key_dup_error storage/blackhole/ha_blackhole.cc: manual merge renamed print_key_dupp_error to print_key_dup_error storage/csv/ha_tina.cc: manual merge renamed print_key_dupp_error to print_key_dup_error mysql-test/valgrind.supp.orig: Manual merge
89 lines
2.5 KiB
C
89 lines
2.5 KiB
C
/* Copyright (C) 2003 MySQL AB
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License as
|
|
published by the Free Software Foundation; either version 2 of the
|
|
License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
USA */
|
|
|
|
#include <my_global.h>
|
|
#include <base64.h>
|
|
#include <tap.h>
|
|
#include <string.h>
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
int i, cmp;
|
|
size_t j, k, l, dst_len, needed_length;
|
|
|
|
for (i= 0; i < 500; i++)
|
|
{
|
|
/* Create source data */
|
|
const size_t src_len= rand() % 1000 + 1;
|
|
|
|
char * src= (char *) malloc(src_len);
|
|
char * s= src;
|
|
char * str;
|
|
char * dst;
|
|
|
|
for (j= 0; j<src_len; j++)
|
|
{
|
|
char c= rand();
|
|
*s++= c;
|
|
}
|
|
|
|
/* Encode */
|
|
needed_length= base64_needed_encoded_length(src_len);
|
|
str= (char *) malloc(needed_length);
|
|
for (k= 0; k < needed_length; k++)
|
|
str[k]= 0xff; /* Fill memory to check correct NUL termination */
|
|
ok(base64_encode(src, src_len, str) == 0,
|
|
"base64_encode: size %d", i);
|
|
ok(needed_length == strlen(str) + 1,
|
|
"base64_needed_encoded_length: size %d", i);
|
|
|
|
/* Decode */
|
|
dst= (char *) malloc(base64_needed_decoded_length(strlen(str)));
|
|
dst_len= base64_decode(str, strlen(str), dst);
|
|
ok(dst_len == src_len, "Comparing lengths");
|
|
|
|
cmp= memcmp(src, dst, src_len);
|
|
ok(cmp == 0, "Comparing encode-decode result");
|
|
if (cmp != 0)
|
|
{
|
|
char buf[80];
|
|
diag(" --------- src --------- --------- dst ---------");
|
|
for (k= 0; k<src_len; k+=8)
|
|
{
|
|
sprintf(buf, "%.4x ", (uint) k);
|
|
for (l=0; l<8 && k+l<src_len; l++)
|
|
{
|
|
unsigned char c= src[k+l];
|
|
sprintf(buf, "%.2x ", (unsigned)c);
|
|
}
|
|
|
|
sprintf(buf, " ");
|
|
|
|
for (l=0; l<8 && k+l<dst_len; l++)
|
|
{
|
|
unsigned char c= dst[k+l];
|
|
sprintf(buf, "%.2x ", (unsigned)c);
|
|
}
|
|
diag(buf);
|
|
}
|
|
diag("src length: %.8x, dst length: %.8x\n",
|
|
(uint) src_len, (uint) dst_len);
|
|
}
|
|
}
|
|
return exit_status();
|
|
}
|