コード例 #1
0
ファイル: ctest.c プロジェクト: bronson/ctest
int ctest_internal_finish_test(int success)
{
	if(!test_head) {
		/* how could we end up here without a test_head?? */
		fprintf(stderr, "Internal finish error: somehow ctest_start didn't complete?\n");
		exit(243);
	}

	if(!test_head->finished) {
		/* we haven't run the test yet, so run it. */
		test_head->finished = 1;
		return 1;
	}

	if(success || test_head->inverted) {
		metrics.test_successes += 1;
	} else {
		metrics.test_failures += 1;
	}

	test_pop();

	if(ctest_preferences.verbosity >= 2) {
		print_test_indentation();
		printf("}\n");
	}

	return 0;
}
コード例 #2
0
ファイル: test_queue.cpp プロジェクト: hundeboll/rlncd
TEST_F(queue_test, order)
{
    test_top();
    test_pop();
    test_clear();
    test_mixed();
}
コード例 #3
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);
}
コード例 #4
0
ファイル: stack.test.c プロジェクト: modulated/uti-c
void test_all()
{
	test_new();
	test_del();
	test_push();
	test_pop();
	test_peek();
}
コード例 #5
0
ファイル: test_simple_fifo.cpp プロジェクト: ClumsyApe/Marlin
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;
}
コード例 #6
0
ファイル: vec.c プロジェクト: vinriviere/m68k-atari-mint-gcc
void
vec_c_tests ()
{
  test_quick_push ();
  test_safe_push ();
  test_truncate ();
  test_safe_grow_cleared ();
  test_pop ();
  test_safe_insert ();
  test_ordered_remove ();
  test_ordered_remove_if ();
  test_unordered_remove ();
  test_block_remove ();
  test_qsort ();
  test_reverse ();
}
コード例 #7
0
ファイル: main.cpp プロジェクト: KKosovcov/hpcourse
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);
}
コード例 #8
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;
    }
  }
}
コード例 #9
0
ファイル: unit_test.c プロジェクト: ALLTERCO/mongoose-iot
static const char *test_general(void) {
  uint8_t seg_size;
  uint8_t stash_size;

  /* Try various stash sizes... */
  for (stash_size = 0; stash_size <= 3; stash_size++) {
    /* And various seg sizes */
    for (seg_size = 1; seg_size <= 16; seg_size <<= 1) {
      struct segstack ss;
      struct segstack_opt opt = {
          .cell_size = 4, .seg_size = seg_size, .stash_segs = stash_size,
      };
      const int maxsize = 500;
      const int maxback = 50;
      const int dropsize = 123;
      int max_segs_num = 0;
      segstack_init(&ss, &opt);

      /* Fill the stack with values */
      int32_t i;
      for (i = 0; i <= maxsize; i++) {
        int32_t val = f(i);
        segstack_push(&ss, &val);
        ASSERT_EQ(num_segs(&ss), (i / seg_size + 1));
      }

      max_segs_num = num_segs(&ss);

      ASSERT(segstack_at(&ss, maxsize + 1) == NULL);
      ASSERT(segstack_at(&ss, -maxsize - 2) == NULL);

      /* Check each element of the stack */
      for (i = 0; i <= maxsize; i++) {
        ASSERT_EQ(*(int32_t *) segstack_at(&ss, i), f(i));
        ASSERT_EQ(num_segs(&ss), (maxsize / seg_size + 1));
      }

      /* Pop various amounts of cells from the stack, and push them back */
      int back;
      for (back = 1; back < maxback; back++) {
        for (i = maxsize; i >= (maxsize - back); i--) {
          const char *t = test_pop(&ss, i, seg_size, max_segs_num, stash_size);
          if (t != NULL) {
            return t;
          }
          int32_t val = 0xa5a5a5a5;
          segstack_push(&ss, &val);
          segstack_pop(&ss, NULL);
        }

        for (i = (maxsize - back); i <= maxsize; i++) {
          int32_t val = f(i);
          segstack_push(&ss, &val);
        }
      }

      /* Drop stack size by dropsize */
      segstack_set_size(&ss, maxsize - dropsize + 1);

      /* Pop all elements from the stack */
      for (i = maxsize - dropsize; i >= 0; i--) {
        const char *t = test_pop(&ss, i, seg_size, max_segs_num, stash_size);
        if (t != NULL) {
          return t;
        }
      }

      /* There should be no TOS, and len is 0 */
      ASSERT_EQ(segstack_size(&ss), 0);
      ASSERT(ss.tos_seg == NULL);

      /* In case of no stash, last_seg should also be NULL */
      if (stash_size == 0) {
        ASSERT(ss.last_seg == NULL);
      }

      segstack_free(&ss);
    }
  }
  return NULL;
}

static const char *run_all_tests(void) {
  RUN_TEST(test_general);
  return NULL;
}