From: Adam Dickmeiss Date: Wed, 20 Jun 2012 11:06:16 +0000 (+0200) Subject: Test base64 system more X-Git-Tag: v4.2.35~7 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=7fb0d7639df297cd23ac4494b3c5001b41b595d0 Test base64 system more --- diff --git a/test/test_embed_record.c b/test/test_embed_record.c index e5e6a02..5472c73 100644 --- a/test/test_embed_record.c +++ b/test/test_embed_record.c @@ -13,18 +13,40 @@ #include #include -#if YAZ_HAVE_XML2 - #include #include #include #include +#if YAZ_HAVE_XML2 + #include #include +#endif void test1(void) { + int buflen; + for (buflen = 0; buflen < 256; buflen++) + { + char buf[256]; + char buf_a[1024]; + char buf_b[1024]; + int i; + for (i = 0; i < buflen; i++) + buf[i] = 1 + i; + buf[i] = 0; + + yaz_base64encode(buf, buf_a); + + YAZ_CHECK(yaz_base64decode(buf_a, buf_b) == 0); + + YAZ_CHECK(strcmp(buf, buf_b) == 0); + } +} + +void test2(void) +{ char base_enc[] = "MDA3NjZuYW0gIDIyMDAyNjU4YSA0NTAwMDAxMDAxMjAwMDAwMDAzMDAwNjAwMDEyMDA1MDAx" "NzAwMDE4MDA4MDA0MTAwMDM1MDEwMDAxNzAwMDc2MDIwMDAxNTAwMDkzMDM1MDAxODAwMTA4" @@ -61,7 +83,6 @@ void test1(void) wrbuf_destroy(buf); } -#endif static int test_render(const char *type_spec, int is_marc, const char *input, const char *expected_output) @@ -115,8 +136,9 @@ int main(int argc, char **argv) { YAZ_CHECK_INIT(argc, argv); YAZ_CHECK_LOG(); -#if YAZ_HAVE_XML2 test1(); + test2(); +#if YAZ_HAVE_XML2 YAZ_CHECK(test_render("xml", 0, "", "")); YAZ_CHECK(test_render(