From: Gonzalo A. <ga...@us...> - 2006-09-08 21:00:49
|
Update of /cvsroot/mod-c/ehtml/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv17786/src Modified Files: Makefile.am Added Files: testCommon.cpp Log Message: Added a testbed for Common routines. Index: Makefile.am =================================================================== RCS file: /cvsroot/mod-c/ehtml/src/Makefile.am,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile.am 8 Sep 2006 14:37:07 -0000 1.6 --- Makefile.am 8 Sep 2006 21:00:46 -0000 1.7 *************** *** 14,17 **** --- 14,18 ---- lib_LTLIBRARIES = libehtml.la libsession.la libdisksession.la libsessionid.la bin_PROGRAMS = mod_c_dss + noinst_PROGRAMS = testCommon EHTML_SOURCES = Common.cpp *************** *** 54,57 **** --- 55,60 ---- libsessionid_la_LDFLAGS = -shared -module + testCommon_SOURCES = testCommon.cpp + #SUBDIRS = dss_tool --- NEW FILE: testCommon.cpp --- #include "Common.cpp" #include "MemBuf.cpp" const char* test[][4] = { { "azAZ09%a%%b", /* plain */ "azAZ09%25a%25%25b", /* url */ "617a415a30392561252562", /* hex */ "YXpBWjA5JWElJWI=" /* b64 */ }, { "a", /* plain */ "a", /* url */ "61", /* hex */ "YQ==" /* b64 */ }, { "ab", /* plain */ "ab", /* url */ "6162", /* hex */ "YWI=" /* b64 */ }, { "abc", /* plain */ "abc", /* url */ "616263", /* hex */ "YWJj", /* b64 */ }, { "abcd", /* plain */ "abcd", /* url */ "61626364", /* hex */ "YWJjZA==" /* b64 */ }, { "abcde", /* plain */ "abcde", /* url */ "6162636465", /* hex */ "YWJjZGU=" /* b64 */ } }; #define NTEST (sizeof(test)/sizeof(test[0])) int main(int argc, char* argv[]) { string s; MemBuf mb; int fail = 0; for (int i = 0; i < NTEST; ++i) { printf("Testing encodings for %s\n", test[i][0]); s = urlencode(test[i][0]); if (strcmp(test[i][1], s.c_str())) { printf("\tURL_FAILED \"%s\" != \"%s\"\n", test[i][1], s.c_str()); ++fail; } mb = urldecode(s); if (strncmp(test[i][0], mb.Char(), mb.Size())) { printf("\tURL_FAILEDr \"%s\" != \"%s\"\n", test[i][0], mb.Char()); ++fail; } s = hexencode(test[i][0]); if (strcasecmp(test[i][2], s.c_str())) { printf("\tHEX_FAILED \"%s\" != \"%s\"\n", test[i][2], s.c_str()); ++fail; } mb = hexdecode(s); if (strncmp(test[i][0], mb.Char(), mb.Size())) { printf("\tHEX_FAILEDr \"%s\" != \"%s\"\n", test[i][0], mb.Char()); ++fail; } s = base64encode(test[i][0]); if (strcmp(test[i][3], s.c_str())) { printf("\tB64_FAILED \"%s\" != \"%s\"\n", test[i][3], s.c_str()); ++fail; } mb = base64decode(s); if (strncmp(test[i][0], mb.Char(), mb.Size())) { printf("\tB64_FAILEDr \"%s\" != \"%s\"\n", test[i][0], mb.Char()); ++fail; } } puts(fail ? "FAIL" : "OK"); return fail ? 1 : 0; } |