exercism

Exercism solutions.
git clone git://code.dwrz.net/exercism
Log | Files | Refs

test_grains.c (1245B)


      1 #include "vendor/unity.h"
      2 #include "../src/grains.h"
      3 
      4 void setUp(void)
      5 {
      6 }
      7 
      8 void tearDown(void)
      9 {
     10 }
     11 
     12 void test_square_1(void)
     13 {
     14    TEST_ASSERT(1ull == square(1));
     15 }
     16 
     17 void test_square_2(void)
     18 {
     19    TEST_ASSERT(2ull == square(2));
     20 }
     21 
     22 void test_square_3(void)
     23 {
     24    TEST_ASSERT(4ull == square(3));
     25 }
     26 
     27 void test_square_4(void)
     28 {
     29    TEST_ASSERT(8ull == square(4));
     30 }
     31 
     32 void test_square_16(void)
     33 {
     34    TEST_ASSERT(32768ull == square(16));
     35 }
     36 
     37 void test_square_32(void)
     38 {
     39    TEST_ASSERT(2147483648ull == square(32));
     40 }
     41 
     42 void test_square_64(void)
     43 {
     44    TEST_ASSERT(9223372036854775808ull == square(64));
     45 }
     46 
     47 void test_square_0_does_not_exist(void)
     48 {
     49    TEST_ASSERT(0 == square(0));
     50 }
     51 
     52 void test_square_greater_than_64_does_not_exist(void)
     53 {
     54    TEST_ASSERT(0 == square(65));
     55 }
     56 
     57 void test_total(void)
     58 {
     59    TEST_ASSERT(18446744073709551615ull == total());
     60 }
     61 
     62 int main(void)
     63 {
     64    UnityBegin("test/test_grains.c");
     65 
     66    RUN_TEST(test_square_1);
     67    RUN_TEST(test_square_2);
     68    RUN_TEST(test_square_3);
     69    RUN_TEST(test_square_4);
     70    RUN_TEST(test_square_16);
     71    RUN_TEST(test_square_32);
     72    RUN_TEST(test_square_64);
     73    RUN_TEST(test_square_0_does_not_exist);
     74    RUN_TEST(test_square_greater_than_64_does_not_exist);
     75    RUN_TEST(test_total);
     76 
     77    return UnityEnd();
     78 }