int
main(int ac, char *av[])
{
    if (ac != 1)
	fprintf(stderr,"Usage: %s \n", av[0]);

    test_encode((const signed char *)"hello world!");
    test_encode((const signed char *)"!@#&#$%@&#$^@(*&^%(#$@&^#*$nasty_string!<>?");

    return 0;
}
Example #2
0
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;
}
Example #3
0
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);
}
Example #4
0
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);
}
Example #5
0
File: test.c Project: zooko/libzstr
int main(int argv, char**argc)
{
	/*test_czstr();*/
	/*test_stream();*/
	test_encode();
	return test_repr();
}
Example #6
0
DEF_GPUTEST(Image_Encode_Gpu, reporter, factory) {
    GrContext* ctx = factory->get(GrContextFactory::kNative_GLContextType);
    if (!ctx) {
        REPORTER_ASSERT(reporter, false);
        return;
    }
    test_encode(reporter, ctx);
}
Example #7
0
void test_protocol_packege_suite()
{
	test_encode();
	test_decode();
	test_codec();
	test_uint32();
	test_package_init();
}
Example #8
0
int
main(int argc, char **argv)
{
	test_encode();
	test_decode();
	test_encrypt();
	test_decrypt();

	return 0;
}
Example #9
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;
}
Example #10
0
int main()
{
  int pass;

  test1();
  for (pass = 0; pass < 1000; pass++)
    {
      buffer = ssh_buffer_allocate();
      test_encode();
      test_empty_decode();
      test_random_decode();
      ssh_buffer_free(buffer);
    }
  ssh_util_uninit();
  return 0;
}
Example #11
0
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;
}
Example #12
0
int main(int argc, char **argv)
{
	test_iterate();
	test_iterate2();
	//print_filler();
	test_filler();
	test_format();
	test_encode();
	test_encode2();
	test_encode3();
	test_encodeNull();
	test_encodeEmpty();
	test_encodeNull8();
	test_encodeEmpty8();
	test_encodeLongData();
	test_01234567();
	test_invalid_input();
//	print_01234567();
	test_struct_example();
	test_struct_semilong();
	test_null_free();
	test_qrraw_new();
	test_mqrraw_new();
	test_encodeData();
	test_formatInfo();
	test_decodeSimple();
	test_decodeLong();
	test_decodeVeryLong();
	//print_fillerMQR();
	test_fillerMQR();
	test_formatInfoMQR();
	test_encodeTooLongMQR();
	test_decodeShortMQR();
	test_oddBitCalcMQR();
	test_mqrencode();
	test_apiversion();

	report();

	return 0;
}
Example #13
0
int main(void)
{
	test_iterate();
	test_iterate2();
	//print_filler();
	test_filler();
	test_format();
	test_encode();
	test_encode2();
	test_encode3();
	test_encodeNull();
	test_encodeEmpty();
	test_encodeNull8();
	test_encodeEmpty8();
	test_encodeTooLong();
	test_01234567();
	test_invalid_input();
//	print_01234567();
	test_struct_example();
	test_struct_semilong();
	test_null_free();
	test_qrraw_new();
	test_mqrraw_new();
	test_encodeData();
	test_formatInfo();
	test_decodeSimple();
	test_decodeLong();
	test_decodeVeryLong();
	//print_fillerMQR();
	test_fillerMQR();
	test_formatInfoMQR();
	test_encodeTooLongMQR();
	test_decodeShortMQR();

	QRcode_clearCache();

	report();

	return 0;
}
Example #14
0
DEF_TEST(Image_Encode_Cpu, reporter) {
    test_encode(reporter, NULL);
}
Example #15
0
int main (int argc, char **argv)
{
    zio_t *zio;
    int init_fds;
    const char *name;
    struct counts c;
    int fd;
    flux_reactor_t *r;
    flux_watcher_t *w;

    memset (&c, 0, sizeof (c));

    plan (NO_PLAN);

    test_encode ();

    ok ((r = flux_reactor_create (0)) != NULL,
        "flux reactor created");

    init_fds = fdcount ();
    diag ("initial fd count: %d", init_fds);

    /* simple reader tests
     */
    ok ((zio = zio_pipe_reader_create ("test1", &c)) != NULL,
        "reader: zio_pipe_reader_create works");
    ok ((name = zio_name (zio)) != NULL && !strcmp (name, "test1"),
        "reader: zio_name returns correct name");
    ok (zio_set_close_cb (zio, close_reader) == 0,
        "reader: zio_set_close_cb works");
    ok (zio_set_send_cb (zio, send_reader) == 0,
        "reader: zio_set_send_cb works");
    ok (zio_reactor_attach (zio, r) == 0,
        "reader: zio_reactor_attach works");
    ok ((fd = zio_dst_fd (zio)) >= 0,
        "reader: zio_dst_fd returned valid file descriptor");
    ok (write (fd, "narf!", 5) == 5,
        "reader: wrote narf! to reader pipe");
    ok (zio_close_dst_fd (zio) == 0,
        "reader: zio_close_dst_fd succeeded");
    ok (flux_reactor_run (r, 0) == 0,
        "reader: reactor completed successfully");
    ok (c.send_reader == 1,
        "reader: send function called once for EOF + incomplete line");
    errno = 0;
    zio_destroy (zio);
    ok (init_fds == fdcount (),
        "reader: zio_destroy leaks no file descriptors");

    /* simple writer tests
     */
    ok ((zio = zio_pipe_writer_create ("test2", &c)) != NULL,
        "writer: zio_pipe_writer_create works");
    ok ((name = zio_name (zio)) != NULL && !strcmp (name, "test2"),
        "writer: zio_name returns correct name");
    ok (zio_set_close_cb (zio, close_writer) == 0,
        "writer: zio_set_close_cb works");
    ok ((fd = zio_src_fd (zio)) >= 0,
        "writer: zio_src_fd returned valid file descriptor");
    w = flux_fd_watcher_create (r, fd, FLUX_POLLIN, fd_read, &c);
    ok (w != NULL,
        "writer: created fd watcher");
    flux_watcher_start (w);
    ok (zio_write (zio, "narf!", 5) == 5,
        "writer: zio_write narf! works");
    ok (zio_write_eof (zio) == 0,
        "writer: zio_write_eof works");
    ok (flux_reactor_run (r, 0) == 0,
        "writer: reactor completed successfully");
    ok (c.fd_read_errors == 0 && c.fd_read_data == 5 && c.fd_read_eof == 1,
        "writer: read narf + EOF on read end of pipe");
    ok (c.close_writer == 1,
        "writer: close callback invoked");

    zio_destroy (zio);
    ok (init_fds == fdcount (),
        "writer: zio_destroy leaks no file descriptors");

    flux_watcher_destroy (w);
    flux_reactor_destroy (r);

    done_testing ();
}
Example #16
0
void test(duk_context *ctx) {
	test_encode(ctx);
	test_decode(ctx);
	/* FIXME: test decode error */
}
Example #17
0
int
main(int ac, char *av[])
{
    int test_num = 0;
    if (ac != 2)
	fprintf(stderr,"Usage: %s test_number\n", av[0]);

    sscanf(av[1], "%d", &test_num);

    switch (test_num) {
	case 1:
	    return test_encode(NULL);
	case 2:
	    return test_encode("");
	case 3:
	    return test_encode(" ");
	case 4:
	    return test_encode("hello");
	case 5:
	    return test_encode("\"");
	case 6:
	    return test_encode("\'");
	case 7:
	    return test_encode("\\");
	case 8:
	    return test_encode("\\\"");
	case 9:
	    return test_encode("\\\\");
	case 10:
	    return test_encode("\"hello\"");
	case 11:
	    return test_encode("\'hello\'");
	case 12:
	    return test_encode("\\hello");
	case 13:
	    return test_encode("\\hello\"");
	case 14:
	    return test_encode("hello\\\\");
	case 15:
	    return test_encode("\"hello\'\"");
	case 16:
	    return test_encode("\"hello\'");
	case 17:
	    return test_encode("\'hello\'");
	case 18:
	    return test_encode("\'hello\"");
	case 19:
	    return test_encode("\"\"hello\"");
	case 20:
	    return test_encode("\'\'hello\'\'");
	case 21:
	    return test_encode("\'\"hello\"\'");
	case 22:
	    return test_encode("\"\"hello\"\"");
	case 23:
	    return test_encode("\"\"\"hello\"\"\"");
	case 24:
	    return test_encode("\"\"\"[exec join $hello {world}]\"\"\"");
    }

    return 1;
}
Example #18
0
int
main() {
	return test_encode("encode.txt");
}
Example #19
0
DEF_TEST(Image_Encode_Cpu, reporter) {
    test_encode(reporter, nullptr);
}
Example #20
0
DEF_TEST(Encode, r) {
    test_encode(r, SkEncodedImageFormat::kJPEG);
    test_encode(r, SkEncodedImageFormat::kPNG);
}
Example #21
0
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageEncode_Gpu, reporter, context) {
    SkAutoTUnref<SkImage> image(create_gpu_image(context));
    test_encode(reporter, image);
}
Example #22
0
DEF_TEST(ImageEncode, reporter) {
    SkAutoTUnref<SkImage> image(create_image());
    test_encode(reporter, image);
}