void _t_common( const void *in, const void *out,
	const uint8_t *expected, size_t expected_size)
{
	int i, retval;

	for (i = 0; i < 2; ++i)
	{
		memset( buffer, 0xFF, sizeof buffer);
		retval = zdo_match_desc_request( buffer, expected_size - i, TEST_ADDR,
			TEST_PROFILE, in, out);

		if (i)
		{
			if (test_compare( retval, -ENOSPC, "%ld",
						"supposedly fit in small buffer"))
			{
				if (retval > 0)
				{
					printf( "returned %d bytes instead of -ENOSPC:", retval);
					hex_dump( buffer, retval, HEX_DUMP_FLAG_TAB);
				}
			}
		}
		else if (! test_bool( retval > 0, "retval indicates error"))
		{
			compare_buffers( buffer, retval,
				expected, expected_size, "unexpected response");

			test_compare( buffer[expected_size], 0xFF, NULL, "buffer overflow");
		}
	}
}
Esempio n. 2
0
int
main(int argc, char **argv)
{
    hx509_context context;
    int ret = 0;

    ret = hx509_context_init(&context);
    if (ret)
	errx(1, "hx509_context_init failed with %d", ret);

    ret += test_name(context, "CN=foo,C=SE");
    ret += test_name(context, "CN=foo,CN=kaka,CN=FOO,DC=ad1,C=SE");
    ret += test_name(context, "1.2.3.4=foo,C=SE");
    ret += test_name_fail(context, "=");
    ret += test_name_fail(context, "CN=foo,=foo");
    ret += test_name_fail(context, "CN=foo,really-unknown-type=foo");

    ret += test_expand(context, "UID=${uid},C=SE", "UID=lha,C=SE");
    ret += test_expand(context, "UID=foo${uid},C=SE", "UID=foolha,C=SE");
    ret += test_expand(context, "UID=${uid}bar,C=SE", "UID=lhabar,C=SE");
    ret += test_expand(context, "UID=f${uid}b,C=SE", "UID=flhab,C=SE");
    ret += test_expand(context, "UID=${uid}${uid},C=SE", "UID=lhalha,C=SE");
    ret += test_expand(context, "UID=${uid}{uid},C=SE", "UID=lha{uid},C=SE");

    ret += test_compare(context);

    hx509_context_free(&context);

    return ret;
}
Esempio n. 3
0
bool torture_usermod(struct torture_context *torture)
{
	NTSTATUS status;
	struct dcerpc_pipe *p;
	struct policy_handle h;
	struct lsa_String domain_name;
	struct dom_sid2 sid;
	uint32_t rid;
	int i;
	char *name;
	TALLOC_CTX *mem_ctx;
	bool ret = true;
	struct dcerpc_binding_handle *b;

	mem_ctx = talloc_init("test_userdel");

	status = torture_rpc_connection(torture,
					&p,
					&ndr_table_samr);

	torture_assert_ntstatus_ok(torture, status, "RPC connect");
	b = p->binding_handle;

	domain_name.string = lpcfg_workgroup(torture->lp_ctx);
	name = talloc_strdup(mem_ctx, TEST_USERNAME);

	if (!test_domain_open(torture, b, &domain_name, mem_ctx, &h, &sid)) {
		ret = false;
		goto done;
	}

	if (!test_user_create(torture, b, mem_ctx, &h, name, &rid)) {
		ret = false;
		goto done;
	}

	for (i = USER_FIELD_FIRST; i <= USER_FIELD_LAST; i++) {
		struct libnet_rpc_usermod m;

		if (!test_usermod(torture, p, mem_ctx, &h, i, &m, &name)) {
			ret = false;
			goto cleanup;
		}

		if (!test_compare(torture, p, mem_ctx, &h, &m, name)) {
			ret = false;
			goto cleanup;
		}
	}

cleanup:
	if (!test_user_cleanup(torture, b, mem_ctx, &h, TEST_USERNAME)) {
		ret = false;
		goto done;
	}

done:
	talloc_free(mem_ctx);
	return ret;
}
Esempio n. 4
0
static void test_type(const char *type) {
        CVariant *cv;
        GVariant *gv;
        GBytes *cb, *gb;
        const void *cd, *gd;

        test_generate(type, &cv, &gv);

        cb = test_cv_get_data_as_bytes(cv);
        gb = g_variant_get_data_as_bytes(gv);

        if (g_bytes_compare(cb, gb)) {
                fprintf(stderr, "FAILED: %s\n", type);

                cd = g_bytes_get_data(cb, NULL);
                gd = g_bytes_get_data(gb, NULL);

                fprintf(stderr, "Buffers: %p:%zu %p:%zu\n",
                        cd, g_bytes_get_size(cb),
                        gd, g_bytes_get_size(gb));

                test_print_cv(cv);
                assert(0);
        }

        test_compare(cv, gv);

        g_bytes_unref(gb);
        g_bytes_unref(cb);
        g_variant_unref(gv);
        c_variant_free(cv);
}
static void rect_tests(struct test *test, int iterations, enum target target)
{
	struct test_target real, ref;
	void (* const ops[])(struct test_target *, struct test_target *) = {
		copy,
		fill,
		put,
	};
	int n;

	printf("Running mixed ops stress against %s: ",
	       test_target_name(target));
	fflush(stdout);

	test_target_create_render(&test->real, target, &real);
	test_target_create_render(&test->ref, target, &ref);

	clear(&real);
	clear(&ref);

	for (n = 0; n < iterations; n++)
		ops[rand() % ARRAY_SIZE(ops)](&real, &ref);

	test_compare(test,
		     real.draw, real.format,
		     ref.draw, ref.format,
		     0, 0, real.width, real.height,
		     "");

	printf("passed [%d iterations]\n", n);

	test_target_destroy_render(&test->real, &real);
	test_target_destroy_render(&test->ref, &ref);
}
int main(void)
{
	int a[] = {-4,1,2,3};
	char * cp = (char *)a;

	int res = test_compare((unsigned char *)cp + 4,(unsigned char *)cp + 8); // +4代表a[1],+8代表a[2]
	printf("%d",res);
}
void t_null_buffer( void)
{
	int retval;

	retval = zdo_match_desc_request( NULL, sizeof both_expected,
		TEST_ADDR, TEST_PROFILE, some_clusters, other_clusters);

	test_compare( retval, -EINVAL, NULL, "function accepted NULL buffer");
}
Esempio n. 8
0
static void general(struct test *t, enum target target)
{
	char buf[1024];
	struct test_target out, ref;
	int a, b, alu, lw, style, cap;
	XSegment seg[NUM_POINTS*NUM_POINTS];
	int n = 0;

	printf("Testing drawing of general line segments (%s): ",
	       test_target_name(target));
	fflush(stdout);

	test_target_create_render(&t->out, target, &out);
	test_target_create_render(&t->ref, target, &ref);

	style = LineSolid;

	for (a = 0; a < NUM_POINTS; a++) {
		for (b = 0; b < NUM_POINTS; b++) {
			seg[n].x1 = points[a].x + 64;
			seg[n].y1 = points[a].y + 64;
			seg[n].x2 = points[b].x + 64;
			seg[n].y2 = points[b].y + 64;
			n++;
		}
	}

	for (alu = 0; alu < 16; alu++) {
		for (cap = CapNotLast; cap <= CapProjecting; cap++) {
			for (lw = 0; lw <= 4; lw++) {
				sprintf(buf,
					"width=%d, cap=%d, alu=%d",
					lw, cap, alu);

				clear(&t->out, &out);
				clear(&t->ref, &ref);

				draw(&t->out, &out, alu, lw, style, cap,
					  seg, n);
				draw(&t->ref, &ref, alu, lw, style, cap,
					  seg, n);

				test_compare(t,
					     out.draw, out.format,
					     ref.draw, ref.format,
					     0, 0, out.width, out.height,
					     buf);
			}
		}
	}

	test_target_destroy_render(&t->out, &out);
	test_target_destroy_render(&t->ref, &ref);

	printf("\n");
}
Esempio n. 9
0
void
TestBB_Run_IMP(TestByteBuf *self, TestBatchRunner *runner) {
    TestBatchRunner_Plan(runner, (TestBatch*)self, 21);
    test_Equals(runner);
    test_Grow(runner);
    test_Clone(runner);
    test_compare(runner);
    test_Mimic(runner);
    test_Cat(runner);
}
void t_no_clusters( void)
{
	int retval;

	retval = zdo_match_desc_request( buffer, sizeof no_clusters_expected,
		TEST_ADDR, TEST_PROFILE, empty_clusters, empty_clusters);

	test_compare( retval, -ENOSPC, NULL,
		"unexpected response when asked to match no clusters");
}
Esempio n. 11
0
int
main (int argc, char **argv)
{
    test_zero_fill ();
    test_crop ();
    test_add ();
    test_compare ();
    
    return unit_test_failures;
}
Esempio n. 12
0
int main ()
{
    BEGIN_TESTS(0);

    test_constructor();
    test_compare();
    test_timezone();


    return END_TESTS;
}
Esempio n. 13
0
/**
 * Main test function
 */
int main(int argc, char **argv)
{
    int err = FALSE;

    config_init(&cfg);
    config_check(&cfg);

    err |= test_compare();

    config_destroy(&cfg);
    return err;
}
static void ref_tests(struct test *t, int reps, int sets, enum target target)
{
	struct test_target out, ref;
	int r, s;

	printf("Testing area fills (%s): ", test_target_name(target));
	fflush(stdout);

	test_target_create_render(&t->out, target, &out);
	clear(&t->out, &out);

	test_target_create_render(&t->ref, target, &ref);
	clear(&t->ref, &ref);

	for (s = 0; s < sets; s++) {
		for (r = 0; r < reps; r++) {
			int x = rand() % (2*out.width) - out.width;
			int y = rand() % (2*out.height) - out.height;
			int w = rand() % out.width;
			int h = rand() % out.height;
			int op = ops[rand() % sizeof(ops)];
			int s_red = rand() % 0xff;
			int s_green = rand() % 0xff;
			int s_blue = rand() % 0xff;
			int s_alpha = rand() % 0xff;
			int m_red = rand() % 0xff;
			int m_green = rand() % 0xff;
			int m_blue = rand() % 0xff;
			int m_alpha = rand() % 0xff;

			fill_rect(&t->out, out.picture,
				  op, x, y, w, h,
				  s_red, s_green, s_blue, s_alpha,
				  m_red, m_green, m_blue, m_alpha);
			fill_rect(&t->ref, ref.picture,
				  op, x, y, w, h,
				  s_red, s_green, s_blue, s_alpha,
				  m_red, m_green, m_blue, m_alpha);
		}

		test_compare(t,
			     out.draw, out.format,
			     ref.draw, ref.format,
			     0, 0, out.width, out.height,
			     "");
	}

	printf("passed [%d iterations x %d]\n", reps, sets);

	test_target_destroy_render(&t->out, &out);
	test_target_destroy_render(&t->ref, &ref);
}
static void rect_tests(struct test *t,
		       int dx, int dy,
		       enum mask mask,
		       int reps, int sets,
		       enum target target)
{
	struct test_target real, ref;
	int r, s;

	printf("Testing area fills (offset %dx%d, mask %s) (%s): ",
	       dx, dy, mask_name(mask), test_target_name(target));
	fflush(stdout);

	test_target_create_render(&t->real, target, &real);
	clear(&t->real, &real);

	test_target_create_render(&t->ref, target, &ref);
	clear(&t->ref, &ref);

	for (s = 0; s < sets; s++) {
		for (r = 0; r < reps; r++) {
			int x = rand() % (2*real.width) - real.width;
			int y = rand() % (2*real.height) - real.height;
			int w = rand() % real.width;
			int h = rand() % real.height;
			int op = ops[rand() % sizeof(ops)];
			int red = rand() % 0xff;
			int green = rand() % 0xff;
			int blue = rand() % 0xff;
			int alpha = rand() % 0xff;

			fill_rect(&t->real, real.picture, op,
				  x, y, w, h, dx, dy, mask,
				  red, green, blue, alpha);
			fill_rect(&t->ref, ref.picture, op,
				  x, y, w, h, dx, dy, mask,
				  red, green, blue, alpha);
		}

		test_compare(t,
			     real.draw, real.format,
			     ref.draw, ref.format,
			     0, 0, real.width, real.height,
			     "");
	}

	printf("passed [%d iterations x %d]\n", reps, sets);

	test_target_destroy_render(&t->real, &real);
	test_target_destroy_render(&t->ref, &ref);
}
Esempio n. 16
0
int main(int argc, const char **argv)
{
	test_create();
	test_to_long_long();
	test_compare();
	test_add();
	test_subtract();
	test_increment();
	test_decrement();
	
	test_performance();

	printf("\nAll tests passed!\n");
	return EXIT_SUCCESS;
};
Esempio n. 17
0
int main(int argc, char **argv)
{
	int v, failures;

	v = (argc > 1) ? atoi(argv[1]) : 0;
	failures = 0;

	failures += test_compare(v);

	if (failures) {
		Test_log_error2("%d failures in %s\n", failures, __FILE__);
	}

	return cap_failures(failures);
}
static void rect_tests(struct test *t, int reps, int sets, enum target target, int use_window)
{
	struct test_target out, ref;
	int r, s;
	printf("Testing area fills (%s, using %s source): ",
	       test_target_name(target), use_window ? "window" : "pixmap");
	fflush(stdout);

	test_target_create_render(&t->out, target, &out);
	clear(&t->out, &out);

	test_target_create_render(&t->ref, target, &ref);
	clear(&t->ref, &ref);

	for (s = 0; s < sets; s++) {
		for (r = 0; r < reps; r++) {
			int x, y, w, h;
			uint8_t red = rand();
			uint8_t green = rand();
			uint8_t blue = rand();

			x = rand() % (out.width - 1);
			y = rand() % (out.height - 1);
			w = 1 + rand() % (out.width - x - 1);
			h = 1 + rand() % (out.height - y - 1);

			fill_rect(&t->out, out.picture,
				  x, y, w, h,
				  red, green, blue);
			fill_rect(&t->ref, ref.picture,
				  x, y, w, h,
				  red, green, blue);
		}

		test_compare(t,
			     out.draw, out.format,
			     ref.draw, ref.format,
			     0, 0, out.width, out.height,
			     "");
	}

	printf("passed [%d iterations x %d]\n", reps, sets);

	test_target_destroy_render(&t->out, &out);
	test_target_destroy_render(&t->ref, &ref);
}
static void rect_tests(struct test *t, int reps, int sets, enum target target, int use_window)
{
	struct test_target real, ref;
	int r, s;

	printf("Testing area fills (%s, using %s source): ",
	       test_target_name(target), use_window ? "window" : "pixmap");
	fflush(stdout);

	test_target_create_render(&t->real, target, &real);
	clear(&t->real, &real);

	test_target_create_render(&t->ref, target, &ref);
	clear(&t->ref, &ref);

	for (s = 0; s < sets; s++) {
		for (r = 0; r < reps; r++) {
			int x = rand() % (real.width - 1);
			int y = rand() % (real.height - 1);
			int w = 1 + rand() % (real.width - x - 1);
			int h = 1 + rand() % (real.height - y - 1);
			int tmpx = w == real.width ? 0 : rand() % (real.width - w);
			int tmpy = h == real.height ? 0 : rand() % (real.height - h);
			uint8_t alu = rand() % (GXset + 1);
			uint32_t fg = rand();

			fill_rect(&t->real, real.draw, real.format,
				  use_window, tmpx, tmpy,
				  alu, x, y, w, h, fg);
			fill_rect(&t->ref, ref.draw, ref.format,
				  use_window, tmpx, tmpy,
				  alu, x, y, w, h, fg);
		}

		test_compare(t,
			     real.draw, real.format,
			     ref.draw, ref.format,
			     0, 0, real.width, real.height,
			     "");
	}

	printf("passed [%d iterations x %d]\n", reps, sets);

	test_target_destroy_render(&t->real, &real);
	test_target_destroy_render(&t->ref, &ref);
}
static void rect_tests(struct test *t, int reps, int sets, enum target target, int use_shm)
{
	struct test_target real, ref;
	int r, s;

	printf("Testing area fills (%s): ", test_target_name(target));
	fflush(stdout);

	test_target_create_render(&t->real, target, &real);
	clear(&t->real, &real);

	test_target_create_render(&t->ref, target, &ref);
	clear(&t->ref, &ref);

	for (s = 0; s < sets; s++) {
		for (r = 0; r < reps; r++) {
			int x = rand() % real.width;
			int y = rand() % real.height;
			int w = rand() % (real.width - x);
			int h = rand() % (real.height - y);
			uint8_t alu = rand() % (GXset + 1);
			int red = rand() % 0xff;
			int green = rand() % 0xff;
			int blue = rand() % 0xff;
			int alpha = rand() % 0xff;
			uint8_t fg = color(red, green, blue, alpha);

			fill_rect(&t->real, real.draw, real.format, use_shm,
				  alu, x, y, w, h, fg);
			fill_rect(&t->ref, ref.draw, ref.format, use_shm,
				  alu, x, y, w, h, fg);
		}

		test_compare(t,
			     real.draw, real.format,
			     ref.draw, ref.format,
			     0, 0, real.width, real.height,
			     "");
	}

	printf("passed [%d iterations x %d]\n", reps, sets);

	test_target_destroy_render(&t->real, &real);
	test_target_destroy_render(&t->ref, &ref);
}
Esempio n. 21
0
my_bool do_test(uint bitsize)
{
  MY_BITMAP map;
  uint32 buf[MAX_TESTED_BITMAP_SIZE];
  if (bitmap_init(&map, buf, bitsize, FALSE))
  {
    diag("init error for bitsize %d", bitsize);
    goto error;
  }
  if (test_set_get_clear_bit(&map,bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_flip_bit(&map,bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_get_all_bits(&map, bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_compare_operators(&map,bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_count_bits_set(&map,bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_get_first_bit(&map,bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_get_next_bit(&map,bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_prefix(&map,bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_compare(&map,bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_intersect(&map,bitsize))
    goto error;
  return FALSE;
error:
  return TRUE;
}
static void rect_tests(struct test *t, int reps, int sets, enum target target)
{
	struct test_target real, ref;
	int r, s;

	printf("Testing general (%s): ", test_target_name(target));
	fflush(stdout);

	test_target_create_render(&t->real, target, &real);
	clear(&t->real, &real);

	test_target_create_render(&t->ref, target, &ref);
	clear(&t->ref, &ref);

	for (s = 0; s < sets; s++) {
		for (r = 0; r < reps; r++) {
			int x = rand() % (2*real.width) - real.width;
			int y = rand() % (2*real.height) - real.height;
			int w = rand() % (2*real.width);
			int h = rand() % (2*real.height);
			uint8_t alu = rand() % (GXset + 1);
			uint32_t fg = rand();
			uint32_t lw = rand() % 4;

			draw_rect(&t->real, real.draw, alu,
				  x, y, w, h, fg, lw);
			draw_rect(&t->ref, ref.draw, alu,
				  x, y, w, h, fg, lw);
		}

		test_compare(t,
			     real.draw, real.format,
			     ref.draw, ref.format,
			     0, 0, real.width, real.height,
			     "");
	}

	printf("passed [%d iterations x %d]\n", reps, sets);

	test_target_destroy_render(&t->real, &real);
	test_target_destroy_render(&t->ref, &ref);
}
Esempio n. 23
0
File: main.c Progetto: ShabbyX/shDS
int main(int argc, char **argv)
{
	bool good = true;

	srand(time(NULL));
	if (argc < 2)
	{
		if (generate_data(RANDOM_SIZE))
			goto exit_no_mem;
	}
	else
	{
		if (read_data(argv[1]))
			goto exit_bad_input;
	}

	good = good && test_init() == 0;
	good = good && test_append() == 0;
	good = good && test_duplicate() == 0;
	good = good && test_links() == 0;
	good = good && test_prepend() == 0;
	good = good && test_links() == 0;
	good = good && test_concat() == 0;
	good = good && test_links() == 0;
	good = good && test_break() == 0;
	good = good && test_links() == 0;
	good = good && test_insert() == 0;
	good = good && test_links() == 0;
	good = good && test_compare() == 0;
	good = good && test_delete() == 0;
	good = good && test_links() == 0;
	good = good && test_clear() == 0;
	good = good && test_free() == 0;

	cleanup_data();

	return good?EXIT_SUCCESS:EXIT_FAILURE;
exit_bad_input:
exit_no_mem:
	cleanup_data();
	return EXIT_FAILURE;
}
Esempio n. 24
0
rtems_task Init(
  rtems_task_argument argument
)
{
  timespec1=&ts1;
  timespec2=&ts2;

  puts( "\n\n*** TEST sptimespec01 ***" );

  test_add();
  test_divide();
  test_divide_by_integer();
  test_compare();
  test_validity();
  test_subtract();
  test_convert();

  puts( "\n*** END OF TEST sptimespec01 ***" );

  rtems_test_exit(0);
}
Esempio n. 25
0
int
main(void) {
  test_construct_with_null();
  test_construct_with_empty_string();
  test_construct_with_nonempty_string();
  test_append_char();
  test_at();
  test_back();
  test_capacity();
  test_clear();
  test_compare();
  test_data();
  test_empty();
  test_free();
  test_front();
  test_length();
  test_max_size();
  test_pop_back();
  test_push_back();
  test_reserve();
  test_resize();
  test_size();
  return EXIT_SUCCESS;
}
Esempio n. 26
0
int
main() {

  // Parser
  test_parse_simple();
  test_parse_major();
  test_parse_minor();
  test_parse_prerelease();
  test_parse_metadata();
  test_parse_prerelerease_metadata();

  // Comparison
  test_compare();
  test_compare_full();
  test_compare_gt();
  test_compare_lt();
  test_compare_eq();
  test_compare_neq();
  test_compare_gte();
  test_compare_lte();
  test_satisfies();

  // Render
  test_render();
  test_bump();
  test_bump_minor();
  test_bump_patch();

  // Clean up
  test_free();

  // Helpers
  test_valid_chars();

  return 0;
}
Esempio n. 27
0
int test_address( const void *result, const void *expected, const char *error)
{
	return test_compare( (long) result, (long) expected, "0x%06lx", error);
}
Esempio n. 28
0
int main(int argc, char **argv)
{
  for (size_t i = 0; i < 128; i++) {
    test_class(PN_OBJECT, i);
    test_class(PN_VOID, i);
    test_class(&noop_class, i);
  }

  for (size_t i = 0; i < 128; i++) {
    test_new(i, PN_OBJECT);
    test_new(i, &noop_class);
  }

  test_finalize();
  test_free();
  test_hashcode();
  test_compare();

  for (int i = 0; i < 1024; i++) {
    test_refcounting(i);
  }

  for (size_t i = 0; i < 4; i++) {
    test_list(i);
  }

  for (size_t i = 0; i < 4; i++) {
    test_list_refcount(i);
  }

  test_list_index();

  test_map();
  test_map_links();

  test_hash();

  test_string(NULL);
  test_string("");
  test_string("this is a test");
  test_string("012345678910111213151617181920212223242526272829303132333435363"
              "738394041424344454647484950515253545556575859606162636465666768");
  test_string("this has an embedded \000 in it");
  test_stringn("this has an embedded \000 in it", 28);

  test_string_format();
  test_string_addf();

  test_build_list();
  test_build_map();
  test_build_map_odd();

  for (int i = 0; i < 64; i++)
  {
    test_map_iteration(i);
  }

  test_list_inspect();
  test_map_inspect();
  test_list_compare();
  test_iterator();
  for (int seed = 0; seed < 64; seed++) {
    for (int size = 1; size <= 64; size++) {
      test_heap(seed, size);
    }
  }

  return 0;
}
int test_multitypestorage()
{
	// init some variables:
	Mat a(10,10,CV_32F, Scalar(0.3));
	Mat b(20,20,CV_32F, Scalar(1.));
	Mat c(10,10,CV_32FC3, Scalar(120.));

	double v(9.);
	double w(19.);

	vector<KeyPoint> kp, kp1;
	kp.push_back(KeyPoint(1.0,-1.0,20));
	kp.push_back(KeyPoint(2.0,21.0,10));

	kp1.push_back(KeyPoint(11.0,-1.0,20));
	kp1.push_back(KeyPoint(2.0,1.0,10));


	vector<vector<DMatch> > m;
	vector<DMatch> _m, _n; 
	_m.push_back(DMatch(1,2,10.)); 
	_m.push_back(DMatch(3,4,4.)); 
	_n.push_back(DMatch(6,2,1.)); 
	_n.push_back(DMatch(5,4,41.)); 
	m.push_back(_m);
	m.push_back(_n);
		

	
	// 0-test:
	//cerr << "test_compare(1,2) = " << test_compare(1,2) << " = 0 (false) " << endl;
	//cerr << "test_compare(1.,1.) = " << test_compare(1.,1.) << " = 1 (true) " << endl;
	//cerr << "test_compare(a,a) = " << test_compare(a,a) << " = 1 " << endl;
	//cerr << "test_compare(a,b) = " << test_compare(a,b) << " = 0 "<< endl;
	//cerr << "test_compare(c,c) = " << test_compare(c,c) << " = 1 "<< endl;
	//cerr << "test_compare(a,c) = " << test_compare(a,c) << " = 0 "<< endl;
	//cerr << "test_compare(v,v) = " << test_compare(v,v) << " = 1 "<< endl;
	//cerr << "test_compare(v,w) = " << test_compare(v,w) << " = 0 "<< endl;
	//cerr << "test_compare(kp,kp) = " << test_compare<KeyPoint>(kp,kp) << " = 1 "<< endl;
	//cerr << "test_compare(kp,kp1) = " << test_compare<KeyPoint>(kp,kp1) << " = 0 "<< endl;
	//cerr << "test_compare(m,m) = " << test_compare<vector<DMatch> >(m,m) << " = 1 "<< endl;
	//cerr << "test_compare(_m,_n) = " << test_compare<DMatch>(_m,_n) << " = 0 "<< endl;


	// init MTStorage:
	MultiTypeStorage storage;	

	// add elements:
	storage.setElement<Mat>("a", a);
	storage.setElement<Mat>("b", b);
	storage.setElement<Mat>("c", c);
	storage.setElement<double>("v", v);
	storage.setElement<double>("w", w);
	storage.setElement<vector<KeyPoint> >("kp", kp);
	storage.setElement<vector<vector<DMatch> > >("m", m);


	// get elements:
	Mat A;
	if (storage.getElement<Mat>("a") != NULL) 
		A = *(storage.getElement<Mat>("a"));
	else{
		cerr << "a is not found !" << endl;
		return -1;
	}

	Mat B; 
	if (storage.getElement<Mat>("b")!=NULL)
		B = *(storage.getElement<Mat>("b"));
	else{
		cerr << "b is not found !" << endl;
		return -1;
	}

	Mat C = *(storage.getElement<Mat>("c"));

	double V = *(storage.getElement<double>("v"));
	double W = *(storage.getElement<double>("w"));
	vector<KeyPoint> KP = *(storage.getElement<vector<KeyPoint> >("kp"));
	vector<vector<DMatch> > M = *(storage.getElement<vector<vector<DMatch> > >("m"));

	// compare:
	int s1 = test_compare(A,a) + test_compare(B,b) + test_compare(C,c) + test_compare(V,v) + test_compare(W,w) + test_compare(KP,kp) + test_compare(M,m);
	if (s1 == 7)
		cerr << "test OK" << endl;
	else
		cerr << "test failed" << endl;


}
Esempio n. 30
0
static void edge_test(struct test *t,
		      enum mask mask,
		      enum edge edge,
		      enum target target)
{
	struct test_target out, ref;
	XRenderColor white = { 0xffff, 0xffff, 0xffff, 0xffff };
	Picture src_ref, src_out;
	XTriangle tri;
	unsigned step, max;

	test_target_create_render(&t->out, target, &out);
	set_edge(t->out.dpy, out.picture, edge);
	src_out = XRenderCreateSolidFill(t->out.dpy, &white);

	test_target_create_render(&t->ref, target, &ref);
	set_edge(t->ref.dpy, ref.picture, edge);
	src_ref = XRenderCreateSolidFill(t->ref.dpy, &white);

	printf("Testing edges (with mask %s and %s edges) (%s): ",
	       mask_name(mask),
	       edge_name(edge),
	       test_target_name(target));
	fflush(stdout);

	max = 2*(out.width + 128 + out.height+128);
	step = 0;
	for (step = 0; step <= max; step++) {
		char buf[80];

		step_to_point(step, out.width, out.height, &tri.p1);
		step_to_point(step + out.width + 128,
			      out.width, out.height,
			      &tri.p2);
		step_to_point(step + out.height + 128 + 2*(out.width + 128),
			      out.width, out.height,
			      &tri.p3);

		sprintf(buf,
			"tri=((%d, %d), (%d, %d), (%d, %d))\n",
			tri.p1.x >> 16, tri.p1.y >> 16,
			tri.p2.x >> 16, tri.p2.y >> 16,
			tri.p3.x >> 16, tri.p3.y >> 16);

		clear(&t->out, &out);
		XRenderCompositeTriangles(t->out.dpy,
					  PictOpSrc,
					  src_out,
					  out.picture,
					  mask_format(t->out.dpy, mask),
					  0, 0,
					  &tri, 1);

		clear(&t->ref, &ref);
		XRenderCompositeTriangles(t->ref.dpy,
					  PictOpSrc,
					  src_ref,
					  ref.picture,
					  mask_format(t->ref.dpy, mask),
					  0, 0,
					  &tri, 1);

		test_compare(t,
			     out.draw, out.format,
			     ref.draw, ref.format,
			     0, 0, out.width, out.height,
			     buf);
	}

	XRenderFreePicture(t->out.dpy, src_out);
	test_target_destroy_render(&t->out, &out);

	XRenderFreePicture(t->ref.dpy, src_ref);
	test_target_destroy_render(&t->ref, &ref);

	printf("pass\n");
}