diff options
author | Andinus <andinus@nand.sh> | 2021-08-11 15:26:15 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2021-08-11 15:26:15 +0530 |
commit | 321825828ac918bad28d0597a8616c6dc9802c3c (patch) | |
tree | 0b8e9cb1012197750eb58e972736319b2a6abac2 /c/grains/test/test_grains.c | |
parent | 2979ef790ac5b8f58495e0dd08cafd6a3a2e30a5 (diff) | |
download | exercism-321825828ac918bad28d0597a8616c6dc9802c3c.tar.gz |
Add solved exercises
Diffstat (limited to 'c/grains/test/test_grains.c')
-rw-r--r-- | c/grains/test/test_grains.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/c/grains/test/test_grains.c b/c/grains/test/test_grains.c new file mode 100644 index 0000000..15c4c37 --- /dev/null +++ b/c/grains/test/test_grains.c @@ -0,0 +1,78 @@ +#include "vendor/unity.h" +#include "../src/grains.h" + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + +static void test_square_1(void) +{ + TEST_ASSERT(1ull == square(1)); +} + +static void test_square_2(void) +{ + TEST_ASSERT(2ull == square(2)); +} + +static void test_square_3(void) +{ + TEST_ASSERT(4ull == square(3)); +} + +static void test_square_4(void) +{ + TEST_ASSERT(8ull == square(4)); +} + +static void test_square_16(void) +{ + TEST_ASSERT(32768ull == square(16)); +} + +static void test_square_32(void) +{ + TEST_ASSERT(2147483648ull == square(32)); +} + +static void test_square_64(void) +{ + TEST_ASSERT(9223372036854775808ull == square(64)); +} + +static void test_square_0_does_not_exist(void) +{ + TEST_ASSERT(0 == square(0)); +} + +static void test_square_greater_than_64_does_not_exist(void) +{ + TEST_ASSERT(0 == square(65)); +} + +static void test_total(void) +{ + TEST_ASSERT(18446744073709551615ull == total()); +} + +int main(void) +{ + UnityBegin("test/test_grains.c"); + + RUN_TEST(test_square_1); + RUN_TEST(test_square_2); + RUN_TEST(test_square_3); + RUN_TEST(test_square_4); + RUN_TEST(test_square_16); + RUN_TEST(test_square_32); + RUN_TEST(test_square_64); + RUN_TEST(test_square_0_does_not_exist); + RUN_TEST(test_square_greater_than_64_does_not_exist); + RUN_TEST(test_total); + + return UnityEnd(); +} |