예제 #1
0
void testEqualIntArrays(void)
{
    int p0[] = {1, 8, 987, -2};
    int p1[] = {1, 8, 987, -2};
    int p2[] = {1, 8, 987, 2};
    int p3[] = {1, 500, 600, 700};

    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p3, 1);
}
TEST(PrimeFactors,FactorsOfTwo)
{
  int expected[] = { 2 };
  int *actual = prime_factors_of(2);
  TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, 1);
  free(actual);
}
예제 #3
0
void testNotEqualIntArrays3(void)
{
    int p0[] = {1, 8, 987, -2};
    int p1[] = {1, 8, 986, -2};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}
예제 #4
0
void testNotEqualIntArraysNullActual(void)
{
    int* p1 = NULL;
    int p0[] = {1, 8, 987, 2};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}
TEST(PrimeFactors,FactorsOfFive_Alt)
{
  int *actual = NULL;
  int expected[] = { 5 };
  int count = alt_prime_factors_of(5, &actual);
  TEST_ASSERT_EQUAL(1, count);
  TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, count);
  free(actual);
}
TEST(PrimeFactors, FactorsOfTwo_Alt)
{
  int expected[] = { 2 };
  int *actual;
  int count = alt_prime_factors_of(2, &actual);
  TEST_ASSERT_EQUAL(1,count);
  TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, count);
  free(actual); 
}
TEST(PrimeFactors,FactorsOfTwentyFour_Alt)
{
  int *actual = NULL;
  int expected[] = { 2, 2, 2, 3 };
  int count = alt_prime_factors_of(24, &actual);
  TEST_ASSERT_EQUAL(4, count);
  TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, count);
  free(actual);
}
예제 #8
0
void test_Median_SortDesc_Should_Return_7_6_3_2_IfGiven_2_7_3_6(void)
{
	int given[] = {2,7,3,6};
	int expect[] = {7,6,3,2};
	int length = sizeof(given) / sizeof(given[0]);

	Median_SortDesc(given, length);

	TEST_ASSERT_EQUAL_INT_ARRAY(expect, given, length);
}
예제 #9
0
void test_Median_SortDesc_Should_Return_5_4_IfGiven_5_4(void)
{
	int given[] = {5,4};
	int expect[] = {5,4};
	int length = sizeof(given) / sizeof(given[0]);

	Median_SortDesc(given, length);

	TEST_ASSERT_EQUAL_INT_ARRAY(expect, given, length);
}
예제 #10
0
void test_Median_SortDesc_Should_Return_3_2_1_IfGiven_2_1_3(void)
{
	int given[] = {2,1,3};
	int expect[] = {3,2,1};
	int length = sizeof(given) / sizeof(given[0]);

	Median_SortDesc(given, length);

	TEST_ASSERT_EQUAL_INT_ARRAY(expect, given, length);
}
예제 #11
0
void test_sorted_data_can_sort_complex_tree(void)
{
   TEST_IGNORE();
   int tree_data[] = { 2, 1, 3, 6, 7, 5 };
   node_t *tree = build_tree(tree_data, ARRAY_SIZE(tree_data));

   int expected[] = { 1, 2, 3, 5, 6, 7 };
   int *actual = sorted_data(tree);
   TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, ARRAY_SIZE(expected));

   free_tree(tree);
   free(actual);
}
예제 #12
0
void test_sorted_data_can_sort_if_second_number_is_greater_than_first(void)
{
   TEST_IGNORE();
   int tree_data[] = { 2, 3 };
   node_t *tree = build_tree(tree_data, ARRAY_SIZE(tree_data));

   int expected[] = { 2, 3 };
   int *actual = sorted_data(tree);
   TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, ARRAY_SIZE(expected));

   free_tree(tree);
   free(actual);
}
예제 #13
0
void test_sorted_data_can_sort_single_number(void)
{
   TEST_IGNORE();
   int tree_data[] = { 2 };
   node_t *tree = build_tree(tree_data, ARRAY_SIZE(tree_data));

   int expected[] = { 2 };
   int *actual = sorted_data(tree);
   TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, ARRAY_SIZE(expected));

   free_tree(tree);
   free(actual);
}
예제 #14
0
void testNotEqualIntArrays3(void)
{
    int p0[] = {1, 8, 987, -2};
    int p1[] = {1, 8, 986, -2};

    int failed;

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4);
    EXPECT_ABORT_END

    failed = Unity.CurrentTestFailed;
    Unity.CurrentTestFailed = 0;

    VERIFY_FAILURE_WAS_CAUGHT
}