Beispiel #1
0
struct ctest_jmp_wrapper* ctest_internal_start_test(const char *name, const char *file, int line)
{
	struct test* test = malloc(sizeof(struct test));
	if(!test) {
		fprintf(stderr, "Out of memory allocating struct test!\n");
		exit(239);
	}

	if(!name || !name[0]) {
		name = "(unnamed)";
	}

	test->name = name;
	test->finished = 0;
	test->inverted = 0;

	metrics.tests_run += 1;
	if(ctest_preferences.verbosity >= 1) {
		print_test_indentation();
		printf("%d. Running %s at %s:%d%s\n",
			metrics.tests_run, name, file, line,
			ctest_preferences.verbosity >= 2 ? " {" : "");
	}

	test_push(test);
	return &test_head->jmp;
}
Beispiel #2
0
/*
 * Some simple tests
 */
static void base_test(void) {
  printf("*****************\n");
  printf("    BASE TESTS\n");
  printf("*****************\n\n");

  init_test_bench(&bench, &poly_table);
  bench.show_details = true;

  test_activate(&bench, 10);
  test_activate(&bench, 2);
  test_activate(&bench, 4);
  test_propagate(&bench);
  test_push(&bench);
  test_activate(&bench, 24);
  test_activate(&bench, 23);
  test_activate(&bench, 41);
  test_activate(&bench, 49);
  test_activate(&bench, 55);
  test_propagate(&bench);
  test_assert_eq(&bench, 4, 2, -12);
  test_assert_eq(&bench, 4, 10, 0);
  test_propagate(&bench);
  test_increase_dlevel(&bench);
  test_assert_eq(&bench, 5, -1, 1223);
  test_propagate(&bench);
  test_assert_eq(&bench, 2, 10, 20); // cause a conflict
  test_propagate(&bench);
  test_backtrack(&bench);
  test_propagate(&bench);
  test_pop(&bench);
  test_propagate(&bench);
  delete_test_bench(&bench);
}
Beispiel #3
0
void test_all()
{
	test_new();
	test_del();
	test_push();
	test_pop();
	test_peek();
}
Beispiel #4
0
int main(int argc, char const *argv[])
{
  test_start();
  
  test_push();
  test_push_grow_array();
  
  test_end();
}
Beispiel #5
0
void
p11_fixture (void (* setup) (void *),
             void (* teardown) (void *))
{
	test_item item;

	item.type = FIXTURE;
	item.x.fix.setup = setup;
	item.x.fix.teardown = teardown;

	test_push (&item);
}
Beispiel #6
0
void
p11_test (void (* function) (void),
          const char *name,
          ...)
{
	test_item item = { TEST, };
	va_list va;

	item.x.test.func = (func_with_arg)function;

	va_start (va, name);
	vsnprintf (item.x.test.name, sizeof (item.x.test.name), name, va);
	va_end (va);

	test_push (&item);
}
Beispiel #7
0
void
p11_testx (void (* function) (void *),
           void *argument,
           const char *name,
           ...)
{
	test_item item = { TEST, };
	va_list va;

	item.type = TEST;
	item.x.test.func = function;
	item.x.test.argument = argument;

	va_start (va, name);
	vsnprintf (item.x.test.name, sizeof (item.x.test.name), name, va);
	va_end (va);

	test_push (&item);
}
int main()
{
    for(int i = 1; i <= 64; i *= 2)
    {
        test_pull(i);
        test_push(i);
        test_both(i);
    }
    //These numbers must divide 1000
    compute_sum(1);
    compute_sum(4);
    compute_sum(10);
    compute_sum(25);
    compute_sum(50);
    sum_with_moving(1);
    sum_with_moving(4);
    sum_with_moving(10);
    sum_with_moving(25);
    sum_with_moving(50);
    return boost::report_errors();
}
Beispiel #9
0
int main()
{
    struct vgscpu_context *c = (struct vgscpu_context *)vgscpu_create_context();
    if (!c) return -1;
    int result = -1;

    if (test_program_memory(c)) goto END_TEST;
    if (test_push(c)) goto END_TEST;
    if (error_push_stack_overflow_1(c)) goto END_TEST;
    if (error_push_stack_overflow_2(c)) goto END_TEST;
    if (error_push_stack_overflow_4(c)) goto END_TEST;
    if (test_pop1(c)) goto END_TEST;
    if (test_pop2(c)) goto END_TEST;
    if (test_pop4(c)) goto END_TEST;
    if (error_pop_stack_underflow(c)) goto END_TEST;

    result = 0;
    puts("success");
END_TEST:
    vgscpu_release_context(c);
    return result;
}
Beispiel #10
0
int main() {
    test_push(TEST_ONLY_BACK);
    test_pop(TEST_ONLY_BACK);
    
    test_push(TEST_ONLY_FRONT);
    test_pop(TEST_ONLY_FRONT);
    
    test_push(TEST_ONLY_BACK);
    test_pop(TEST_RANDOM);
    
    test_push(TEST_RANDOM);
    test_pop(TEST_ONLY_BACK);
    
    test_push(TEST_RANDOM);
    test_pop(TEST_ONLY_FRONT);
    
    test_push(TEST_RANDOM);
    test_pop(TEST_RANDOM);
}
Beispiel #11
0
int main() {

	SimpleFifo<int> f(4);
	std::cout << "== Using FIFO of size " << f.size() << " ==" << std::endl;

	test_push(f, 3);

	test_pop(f);
	test_pop(f);

	test_push(f, 117);
	test_push(f, -80);

	test_pop(f);

	test_push(f, 999);
	test_push(f, 101);
	test_push(f, 2);
	test_push(f, 54);

	test_pop(f);

	return 0;
}
Beispiel #12
0
/*
 * Random test: give more weight to assert_eq and propagate
 * - if there's a conflict, try to resolve it first
 */
static void random_op(test_bench_t *bench) {
  uint32_t r;

  if (bench->mngr_conflict) {
    if (bench->decision_level > bench->base_level) {
      test_backtrack(bench);
    } else if (bench->base_level > 0) {
      test_pop(bench);
    }
  } else {
    r = random_index(15);
    switch (r) {
    case 0:
    case 1:
    case 2:
    case 3:
    case 4:
      random_assert_eq(bench);
      break;

    case 5:
      random_assert_eq(bench);
    case 6:
      random_assert_eq(bench);
    case 7:
      random_assert_eq(bench);
    case 8:
      test_propagate(bench);
      break;

    case 9:
      random_activate(bench, 1);
      break;

    case 10:
    case 11:
      // increase decision level: force propagate first
      test_propagate(bench);
      if (! bench->mngr_conflict) {
	test_increase_dlevel(bench);
      }
      break;

    case 12:
      // push
      if (bench->decision_level == bench->base_level) {
	test_push(bench);
      }
      break;

    case 13:
      // backtrack
      if (bench->decision_level > bench->base_level) {
	test_backtrack(bench);
      }
      break;

    case 14:
      // pop
      if (bench->base_level > 0) {
	test_pop(bench);
      }
      break;

    default:
      assert(false);
      break;
    }
  }
}