int main(int argc, char *argv[]) { ps_decoder_t *ps; cmd_ln_t *config; int rv; TEST_ASSERT(config = cmd_ln_init(NULL, ps_args(), TRUE, "-hmm", MODELDIR "/en-us/en-us", "-lm", MODELDIR "/en-us/en-us.lm.dmp", "-dict", MODELDIR "/en-us/cmudict-en-us.dict", "-fwdtree", "yes", "-fwdflat", "no", "-bestpath", "yes", "-input_endian", "little", "-cmninit", "37", "-samprate", "16000", NULL)); TEST_ASSERT(ps = ps_init(config)); rv = test_decode(ps); ps_free(ps); cmd_ln_free_r(config); return rv; }
static void runtest_encdec(const char *json_base_fn) { char *json_fn = test_filename(json_base_fn); cJSON *tests = read_json(json_fn); assert((tests->type & 0xFF) == cJSON_Array); unsigned int idx; for (idx = 0; idx < cJSON_GetArraySize(tests); idx++) { cJSON *test = cJSON_GetArrayItem(tests, idx); assert((test->type & 0xFF) == cJSON_Array); assert(cJSON_GetArraySize(test) == 2); cJSON *j_raw = cJSON_GetArrayItem(test, 0); cJSON *j_enc = cJSON_GetArrayItem(test, 1); assert((j_raw->type & 0xFF) == cJSON_String); assert((j_enc->type & 0xFF) == cJSON_String); test_encode(j_raw->valuestring, j_enc->valuestring); test_decode(j_raw->valuestring, j_enc->valuestring); } free(json_fn); cJSON_Delete(tests); }
int main(int argc, char **argv) { size_t ncases = sizeof(testcases) / sizeof(testcases[0]); size_t i; struct testcase *t; int status = 0, verbose = 0; /* Is this a "high" 4-byte encoding above U+10FFFF? */ int high4; if (argc == 2 && strcmp(argv[1], "-v") == 0) verbose = 1; for (i = 0; i < ncases; i++) { t = &testcases[i]; if (verbose) printtest(t); #ifndef OLDENCODINGS high4 = t->ucs > 0x10ffff; #else high4 = 0; #endif if (test_decode(t, high4) != 0) status = 1; if (t->ucs == 0) continue; if (test_encode(t, high4) != 0) status = 1; } return status; }
static void runtest_encdec(const char *base_fn) { char *fn = NULL; fn = test_filename(base_fn); json_t *data = read_json(fn); assert(json_is_array(data)); size_t n_tests = json_array_size(data); unsigned int i; for (i = 0; i < n_tests; i++) { json_t *inner; inner = json_array_get(data, i); assert(json_is_array(inner)); json_t *j_raw = json_array_get(inner, 0); json_t *j_enc = json_array_get(inner, 1); assert(json_is_string(j_raw)); assert(json_is_string(j_enc)); test_encode(json_string_value(j_raw), json_string_value(j_enc)); test_decode(json_string_value(j_raw), json_string_value(j_enc)); } free(fn); json_decref(data); }
void test_protocol_packege_suite() { test_encode(); test_decode(); test_codec(); test_uint32(); test_package_init(); }
int main (int argc, char *argv[]) { int failed = 0; int i; char buf[1000]; g_print ("Testing base64 encoding ...\n"); failed += string_encode_decode (""); failed += string_encode_decode ("A"); failed += string_encode_decode ("AB"); failed += string_encode_decode ("ABC"); failed += string_encode_decode ("ABCD"); failed += string_encode_decode ("ABCDE"); failed += string_encode_decode ("ABCDEF"); failed += string_encode_decode ("ABCDEFG"); failed += string_encode_decode ("ABCDEFGH"); failed += string_encode_decode ("ABCDEFGHI"); failed += string_encode_decode ("abcdefghik"); failed += string_encode_decode ("1234567890abcdefghijklmnopqrstuvwxyz"); failed += string_encode_decode ("«© Raphaël»"); for (i = 0; i < sizeof (buf); i++) buf[i] = (char) (i % 0xff); failed += buffer_encode_decode (buf, sizeof (buf), 0); failed += buffer_encode_decode (buf, sizeof (buf), 76); failed += buffer_encode_decode (buf, sizeof (buf), 4); failed += buffer_encode_decode (buf, sizeof (buf), 1); for (i = 0; i < sizeof (buf); i++) buf[i] = (char) (0xff - (i % 0xff)); failed += buffer_encode_decode (buf, 600, 0); failed += buffer_encode_decode (buf, 500, 0); failed += buffer_encode_decode (buf, 400, 0); failed += test_decode ("QUJD", "ABC", 3, FALSE); failed += test_decode (" Q\tU J\nDR\rA==", "ABCD", 4, FALSE); failed += test_decode ("?", "", -1, FALSE); failed += test_decode ("?", "", 0, TRUE); failed += test_decode ("////", "\377\377\377", 3, FALSE); failed += test_decode ("---/./(/)/*", "", -1, FALSE); failed += test_decode ("---/./(/)/*", "\377\377\377", 3, TRUE); failed += test_decode ("AA==", "\0", 1, FALSE); failed += test_decode ("AAA=", "\0\0", 2, FALSE); if (failed > 0) { g_print ("%d test(s) failed!\n", failed); return EXIT_FAILURE; } g_print ("No problems detected.\n"); return EXIT_SUCCESS; }
int main(int argc, char **argv) { test_encode(); test_decode(); test_encrypt(); test_decrypt(); return 0; }
int main (int argc, char ** argv) { printf ("HEXCODE TESTS\n"); printf ("===============\n\n"); init (argc, argv); test_encode (); test_decode (); test_reversibility (); test_config (); print_result ("testmod_hexcode"); return nbError; }
int main (int argc, char ** argv) { printf ("CCODE TESTS\n"); printf ("=============\n\n"); init (argc, argv); test_encode (); test_decode (); test_reversibility (); test_decodeescape (); test_config (); test_otherescape (); printf ("\ntest_backendhelpers RESULTS: %d test(s) done. %d error(s).\n", nbTest, nbError); return nbError; }
void test(duk_context *ctx) { test_encode(ctx); test_decode(ctx); /* FIXME: test decode error */ }
int main (void) { int val; (void)setvbuf (stdout, NULL, _IONBF, 0); test_decode ("this_should_not_be_modified_1234", "this_should_not_be_modified_1234"); test_decode ("This%20should%20be%20modified%201234!", "This should be modified 1234!"); test_decode ("%7E", "~"); /* tests with invalid input */ test_decode ("%", NULL); test_decode ("%2", NULL); test_decode ("%0000", ""); /* Non-ASCII tests */ test_decode ("T%C3%a9l%c3%A9vision %e2%82%Ac", "Télévision €"); test_decode ("T%E9l%E9vision", "T\xe9l\xe9vision"); /* Base 64 tests */ test_b64 ("", ""); test_b64 ("f", "Zg=="); test_b64 ("fo", "Zm8="); test_b64 ("foo", "Zm9v"); test_b64 ("foob", "Zm9vYg=="); test_b64 ("fooba", "Zm9vYmE="); test_b64 ("foobar", "Zm9vYmFy"); /* Path test */ test_path ("/", "file:///"); test_path ("/home/john/", "file:///home/john/"); test_path ("/home/john//too///many//slashes", "file:///home/john//too///many//slashes"); test_path ("/home/john/music.ogg", "file:///home/john/music.ogg"); /*int fd = open (".", O_RDONLY); assert (fd != -1);*/ val = chdir ("/tmp"); assert (val != -1); char buf[256]; char * tmpdir; tmpdir = getcwd(buf, sizeof(buf)/sizeof(*buf)); assert (tmpdir); test_current_directory_path ("movie.ogg", tmpdir, "movie.ogg"); test_current_directory_path (".", tmpdir, "."); test_current_directory_path ("", tmpdir, ""); /*val = fchdir (fd); assert (val != -1);*/ /* URI to path tests */ #define test( a, b ) test (vlc_uri2path, a, b) test ("mailto:[email protected]", NULL); test ("http://www.example.com/file.html#ref", NULL); test ("file://", NULL); test ("file:///", "/"); test ("file://localhost/home/john/music%2Eogg", "/home/john/music.ogg"); test ("file://localhost/home/john/text#ref", "/home/john/text"); test ("file://localhost/home/john/text?name=value", "/home/john/text"); test ("file://localhost/home/john/text?name=value#ref", "/home/john/text"); test ("file://?name=value", NULL); test ("file:///?name=value", "/"); test ("fd://0foobar", NULL); test ("fd://0#ref", "/dev/stdin"); test ("fd://1", "/dev/stdout"); test ("fd://12345", "/dev/fd/12345"); #undef test test_url_parse("http://example.com", "http", NULL, NULL, "example.com", 0, NULL, NULL); test_url_parse("http://example.com/", "http", NULL, NULL, "example.com", 0, "/", NULL); test_url_parse("http://[2001:db8::1]", "http", NULL, NULL, "2001:db8::1", 0, NULL, NULL); test_url_parse("protocol://*****:*****@1.2.3.4:567", "protocol", "john", "doe", "1.2.3.4", 567, NULL, NULL); test_url_parse("http://a.b/?opt=val", "http", NULL, NULL, "a.b", 0, "/", "opt=val"); test_url_parse("p://*****:*****@host:123/a/b/c?o=v", "p", "u", "p", "host", 123, "/a/b/c", "o=v"); test_url_parse("p://?o=v", "p", NULL, NULL, "", 0, NULL, "o=v"); test_url_parse("p://h?o=v", "p", NULL, NULL, "h", 0, NULL, "o=v"); test_url_parse("p://*****:*****@h:123?o=v", "p", "u", "p", "h", 123, NULL, "o=v"); test_url_parse("p://white%20spaced", "p", NULL, NULL, "white%20spaced", 0, NULL, NULL); test_url_parse("p://h/white%20spaced", "p", NULL, NULL, "h", 0, "/white%20spaced", NULL); /* Invalid URIs */ test_url_parse("p://G a r b a g e", "p", NULL, NULL, NULL, 0, NULL, NULL); test_url_parse("p://h/G a r b a g e", "p", NULL, NULL, "h", 0, NULL, NULL); return 0; }
int main(int argc, char *argv[]) { char buf[256]; void *code ; int kk ; int i ; int *ixs ; int lim = GF_SIZE + 1 ; if (lim > 1024) lim = 1024 ; #if 0 test_gf(); #endif for ( kk = KK ; kk > 2 ; kk-- ) { code = fec_new(kk, lim); ixs = my_malloc(kk * sizeof(int), "ixs" ); for (i=0; i<kk; i++) ixs[i] = kk - i ; sprintf(buf, "kk=%d, kk - i", kk); test_decode(code, kk, ixs, SZ, buf); for (i=0; i<kk; i++) ixs[i] = i ; test_decode(code, kk, ixs, SZ, "i"); if (0) { for (i=0; i<kk; i++) ixs[i] = i ; ixs[0] = ixs[kk/2] ; test_decode(code, kk, ixs, SZ, "0 = 1 (error expected)"); } if (0) for (i= lim-1 ; i >= kk ; i--) { int j ; for (j=0; j<KK; j++) ixs[j] = kk - j ; ixs[0] = i ; test_decode(code, kk, ixs, SZ, "0 = big"); } if (0) for (i= lim - kk ; i >= 0 && i>= lim - kk - 4 ; i--) { int j ; for (j=0; j<kk; j++) ixs[j] = kk -1 - j + i ; test_decode(code, kk, ixs, SZ, "shifted j"); } if (1) { int j, max_i0 = KK/2 ; if (max_i0 + KK > lim) max_i0 = lim - KK ; for (i= 0 ; i <= max_i0 ; i++) { for (j=0; j<kk; j++) ixs[j] = j + i ; test_decode(code, kk, ixs, SZ, "shifted j"); } } fprintf(stderr, "\n"); free(ixs); fec_free(code); } return 0; }
int main (void) { int val; (void)setvbuf (stdout, NULL, _IONBF, 0); test_decode ("this_should_not_be_modified_1234", "this_should_not_be_modified_1234"); test_decode ("This+should+be+modified+1234!", "This should be modified 1234!"); test_decode ("This%20should%20be%20modified%201234!", "This should be modified 1234!"); test_decode ("%7E", "~"); /* tests with invalid input */ test_decode ("%", "%"); test_decode ("%2", "%2"); test_decode ("%0000", ""); /* UTF-8 tests */ test_decode ("T%C3%a9l%c3%A9vision+%e2%82%Ac", "Télévision €"); test_decode ("T%E9l%E9vision", "T?l?vision"); test_decode ("%C1%94%C3%a9l%c3%A9vision", "??élévision"); /* overlong */ /* Base 64 tests */ test_b64 ("", ""); test_b64 ("f", "Zg=="); test_b64 ("fo", "Zm8="); test_b64 ("foo", "Zm9v"); test_b64 ("foob", "Zm9vYg=="); test_b64 ("fooba", "Zm9vYmE="); test_b64 ("foobar", "Zm9vYmFy"); /* Path test */ test_path ("file:///", "file:///"); test_path ("http://www.example.com/%7Ejohn/", "http://www.example.com/%7Ejohn/"); test_path ("/", "file:///"); test_path ("/home/john/", "file:///home/john/"); test_path ("/home/john/music.ogg", "file:///home/john/music.ogg"); test_path ("\\\\server/pub/music.ogg", "smb://server/pub/music.ogg"); test_path ("\\\\server\\pub\\music.ogg", "smb://server/pub/music.ogg"); /*int fd = open (".", O_RDONLY); assert (fd != -1);*/ val = chdir ("/tmp"); assert (val != -1); char buf[256]; char * tmpdir; tmpdir = getcwd(buf, sizeof(buf)/sizeof(*buf)); assert (tmpdir); test_current_directory_path ("movie.ogg", tmpdir, "movie.ogg"); test_current_directory_path (".", tmpdir, "."); test_current_directory_path ("", tmpdir, ""); /*val = fchdir (fd); assert (val != -1);*/ return 0; }