summary refs log tree commit diff stats
path: root/c/grains/test/test_grains.c
blob: 15c4c375bfac1af8e17fff203eb1908fc9befeaa (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
73
74
75
76
77
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();
}