From 48c52b7ae2987741bcf0eca7e5fd008932932cb6 Mon Sep 17 00:00:00 2001 From: ornse01 Date: Mon, 9 Jan 2012 07:58:11 +0000 Subject: [PATCH] add testcase for gzip header variation. - filename and comment in gzip header. git-svn-id: http://svn.sourceforge.jp/svnroot/bchan/bchanf/trunk@334 20a0b8eb-f62a-4a12-8fe1-b598822500fb --- src/http/test_http_contentdecoder.c | 87 +++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/src/http/test_http_contentdecoder.c b/src/http/test_http_contentdecoder.c index 1a73197..63ec821 100644 --- a/src/http/test_http_contentdecoder.c +++ b/src/http/test_http_contentdecoder.c @@ -1090,6 +1090,53 @@ LOCAL UB testdata_gzip_01[] = { 0xd1, 0x58, 0xb4, 0xe5, 0x16, 0x00, 0x00, }; +/* no filename and no comment in gzip header */ +LOCAL UB testdata_gzip_02[] = { + 0x1f, 0x8b, 0x08, 0x00, 0x12, 0x9c, 0x0a, 0x4f, + 0x00, 0x03, 0x4b, 0x4c, 0x4a, 0x4e, 0x49, 0x4d, + 0x4b, 0xcf, 0xc8, 0xcc, 0xca, 0xce, 0xc9, 0xcd, + 0xcb, 0x2f, 0x28, 0x2c, 0x2a, 0x2e, 0x29, 0x2d, + 0x2b, 0xaf, 0xa8, 0xac, 0x02, 0x00, 0xbd, 0x50, + 0x27, 0x4c, 0x1a, 0x00, 0x00, 0x00, +}; +/* a filename and no comment in gzip header */ +LOCAL UB testdata_gzip_03[] = { + 0x1f, 0x8b, 0x08, 0x08, 0x12, 0x9c, 0x0a, 0x4f, + 0x00, 0x03, 0x6e, 0x61, 0x6d, 0x65, 0x2e, 0x74, + 0x78, 0x74, 0x00, 0x4b, 0x4c, 0x4a, 0x4e, 0x49, + 0x4d, 0x4b, 0xcf, 0xc8, 0xcc, 0xca, 0xce, 0xc9, + 0xcd, 0xcb, 0x2f, 0x28, 0x2c, 0x2a, 0x2e, 0x29, + 0x2d, 0x2b, 0xaf, 0xa8, 0xac, 0x02, 0x00, 0xbd, + 0x50, 0x27, 0x4c, 0x1a, 0x00, 0x00, 0x00, +}; +/* no filename and a comment in gzip header */ +LOCAL UB testdata_gzip_04[] = { + 0x1f, 0x8b, 0x08, 0x10, 0x12, 0x9c, 0x0a, 0x4f, + 0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x20, 0x64, + 0x61, 0x74, 0x61, 0x00, 0x4b, 0x4c, 0x4a, 0x4e, + 0x49, 0x4d, 0x4b, 0xcf, 0xc8, 0xcc, 0xca, 0xce, + 0xc9, 0xcd, 0xcb, 0x2f, 0x28, 0x2c, 0x2a, 0x2e, + 0x29, 0x2d, 0x2b, 0xaf, 0xa8, 0xac, 0x02, 0x00, + 0xbd, 0x50, 0x27, 0x4c, 0x1a, 0x00, 0x00, 0x00, +}; +/* a filename and a comment in gzip header */ +LOCAL UB testdata_gzip_05[] = { + 0x1f, 0x8b, 0x08, 0x18, 0x12, 0x9c, 0x0a, 0x4f, + 0x00, 0x03, 0x6e, 0x61, 0x6d, 0x65, 0x2e, 0x74, + 0x78, 0x74, 0x00, 0x74, 0x65, 0x73, 0x74, 0x20, + 0x64, 0x61, 0x74, 0x61, 0x00, 0x4b, 0x4c, 0x4a, + 0x4e, 0x49, 0x4d, 0x4b, 0xcf, 0xc8, 0xcc, 0xca, + 0xce, 0xc9, 0xcd, 0xcb, 0x2f, 0x28, 0x2c, 0x2a, + 0x2e, 0x29, 0x2d, 0x2b, 0xaf, 0xa8, 0xac, 0x02, + 0x00, 0xbd, 0x50, 0x27, 0x4c, 0x1a, 0x00, 0x00, + 0x00, +}; + +/* expected result for testdata_gzip_02 - testdata_gzip_05*/ +LOCAL UB testdata_identity_02[] = { + "abcdefghijklmnopqrstuvwxyz" +}; + LOCAL UNITTEST_RESULT test_http_contentdecoder_common_perone(HTTP_CONTENTCODING_VALUE type, UB *testdata, W testdata_len, W devide_len, UB *expected, W expected_len) { http_contentdecoder_t decoder; @@ -1250,10 +1297,50 @@ LOCAL UNITTEST_RESULT test_http_contentdecoder_gzip_1() return test_http_contentdecoder_common(HTTP_CONTENTCODING_VALUE_GZIP, testdata, testdata_len, expected, expected_len); } +LOCAL UNITTEST_RESULT test_http_contentdecoder_gzip_2() +{ + UB *testdata = testdata_gzip_02; + W testdata_len = sizeof(testdata_gzip_02); + UB *expected = testdata_identity_02; + W expected_len = strlen(testdata_identity_02); + return test_http_contentdecoder_common(HTTP_CONTENTCODING_VALUE_GZIP, testdata, testdata_len, expected, expected_len); +} + +LOCAL UNITTEST_RESULT test_http_contentdecoder_gzip_3() +{ + UB *testdata = testdata_gzip_03; + W testdata_len = sizeof(testdata_gzip_03); + UB *expected = testdata_identity_02; + W expected_len = strlen(testdata_identity_02); + return test_http_contentdecoder_common(HTTP_CONTENTCODING_VALUE_GZIP, testdata, testdata_len, expected, expected_len); +} + +LOCAL UNITTEST_RESULT test_http_contentdecoder_gzip_4() +{ + UB *testdata = testdata_gzip_04; + W testdata_len = sizeof(testdata_gzip_04); + UB *expected = testdata_identity_02; + W expected_len = strlen(testdata_identity_02); + return test_http_contentdecoder_common(HTTP_CONTENTCODING_VALUE_GZIP, testdata, testdata_len, expected, expected_len); +} + +LOCAL UNITTEST_RESULT test_http_contentdecoder_gzip_5() +{ + UB *testdata = testdata_gzip_05; + W testdata_len = sizeof(testdata_gzip_05); + UB *expected = testdata_identity_02; + W expected_len = strlen(testdata_identity_02); + return test_http_contentdecoder_common(HTTP_CONTENTCODING_VALUE_GZIP, testdata, testdata_len, expected, expected_len); +} + /* */ EXPORT VOID test_httpcontentdecoder_main(unittest_driver_t *driver) { UNITTEST_DRIVER_REGIST(driver, test_http_contentdecoder_identity_1); UNITTEST_DRIVER_REGIST(driver, test_http_contentdecoder_gzip_1); + UNITTEST_DRIVER_REGIST(driver, test_http_contentdecoder_gzip_2); + UNITTEST_DRIVER_REGIST(driver, test_http_contentdecoder_gzip_3); + UNITTEST_DRIVER_REGIST(driver, test_http_contentdecoder_gzip_4); + UNITTEST_DRIVER_REGIST(driver, test_http_contentdecoder_gzip_5); } -- 2.11.0