Responses for exercises in Exercism.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.8 KiB

#include "test-framework/unity.h"
#include "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_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();
}