summary refs log tree commit diff stats
path: root/c/armstrong-numbers/test/test_armstrong_numbers.c
blob: 6e3b222e00f132d7f2779657f7fd9f6a8c982a7e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "vendor/unity.h"
#include "../src/armstrong_numbers.h"

void setUp(void)
{
}

void tearDown(void)
{
}

static void test_zero_is_an_armstrong_number(void)
{
   TEST_ASSERT_TRUE(is_armstrong_number(0));
}

static void test_single_digit_numbers_are_armstrong_numbers(void)
{
   TEST_ASSERT_TRUE(is_armstrong_number(5));
}

static void test_there_are_no_two_digit_armstrong_numbers(void)
{
   TEST_ASSERT_FALSE(is_armstrong_number(10));
}

static void test_three_digit_number_that_is_an_armstrong_number(void)
{
   TEST_ASSERT_TRUE(is_armstrong_number(153));
}

static void test_three_digit_number_that_is_not_an_armstrong_number(void)
{
   TEST_ASSERT_FALSE(is_armstrong_number(100));
}

static void test_four_digit_number_that_is_an_armstrong_number(void)
{
   TEST_ASSERT_TRUE(is_armstrong_number(9474));
}

static void test_four_digit_number_that_is_not_an_armstrong_number(void)
{
   TEST_ASSERT_FALSE(is_armstrong_number(9475));
}

static void test_seven_digit_number_that_is_an_armstrong_number(void)
{
   TEST_ASSERT_TRUE(is_armstrong_number(9926315));
}

static void test_seven_digit_number_that_is_not_an_armstrong_number(void)
{
   TEST_ASSERT_FALSE(is_armstrong_number(9926314));
}

int main(void)
{
   UnityBegin("test/test_armstrong_numbers.c");

   RUN_TEST(test_zero_is_an_armstrong_number);
   RUN_TEST(test_single_digit_numbers_are_armstrong_numbers);
   RUN_TEST(test_there_are_no_two_digit_armstrong_numbers);
   RUN_TEST(test_three_digit_number_that_is_an_armstrong_number);
   RUN_TEST(test_three_digit_number_that_is_not_an_armstrong_number);
   RUN_TEST(test_four_digit_number_that_is_an_armstrong_number);
   RUN_TEST(test_four_digit_number_that_is_not_an_armstrong_number);
   RUN_TEST(test_seven_digit_number_that_is_an_armstrong_number);
   RUN_TEST(test_seven_digit_number_that_is_not_an_armstrong_number);

   return UnityEnd();
}