mirror of
https://codeberg.org/andyscott/exercism.git
synced 2024-11-14 07:10:48 -05:00
71 lines
1.6 KiB
C
71 lines
1.6 KiB
C
|
#include "grains.h"
|
||
|
#include "test-framework/unity.h"
|
||
|
|
||
|
void setUp(void) {}
|
||
|
|
||
|
void tearDown(void) {}
|
||
|
|
||
|
static void test_square_1(void) { TEST_ASSERT_EQUAL_UINT64(1ull, square(1)); }
|
||
|
|
||
|
static void test_square_2(void) {
|
||
|
/* TEST_IGNORE(); // delete this line to run test */
|
||
|
TEST_ASSERT_EQUAL_UINT64(2ull, square(2));
|
||
|
}
|
||
|
|
||
|
static void test_square_3(void) {
|
||
|
/* TEST_IGNORE(); */
|
||
|
TEST_ASSERT_EQUAL_UINT64(4ull, square(3));
|
||
|
}
|
||
|
|
||
|
static void test_square_4(void) {
|
||
|
/* TEST_IGNORE(); */
|
||
|
TEST_ASSERT_EQUAL_UINT64(8ull, square(4));
|
||
|
}
|
||
|
|
||
|
static void test_square_16(void) {
|
||
|
/* TEST_IGNORE(); */
|
||
|
TEST_ASSERT_EQUAL_UINT64(32768ull, square(16));
|
||
|
}
|
||
|
|
||
|
static void test_square_32(void) {
|
||
|
/* TEST_IGNORE(); */
|
||
|
TEST_ASSERT_EQUAL_UINT64(2147483648ull, square(32));
|
||
|
}
|
||
|
|
||
|
static void test_square_64(void) {
|
||
|
/* TEST_IGNORE(); */
|
||
|
TEST_ASSERT_EQUAL_UINT64(9223372036854775808ull, square(64));
|
||
|
}
|
||
|
|
||
|
static void test_square_0_does_not_exist(void) {
|
||
|
/* TEST_IGNORE(); */
|
||
|
TEST_ASSERT_EQUAL_UINT64(0, square(0));
|
||
|
}
|
||
|
|
||
|
static void test_square_greater_than_64_does_not_exist(void) {
|
||
|
/* TEST_IGNORE(); */
|
||
|
TEST_ASSERT_EQUAL_UINT64(0, square(65));
|
||
|
}
|
||
|
|
||
|
static void test_total(void) {
|
||
|
/* TEST_IGNORE(); */
|
||
|
TEST_ASSERT_EQUAL_UINT64(18446744073709551615ull, total());
|
||
|
}
|
||
|
|
||
|
int main(void) {
|
||
|
UNITY_BEGIN();
|
||
|
|
||
|
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 UNITY_END();
|
||
|
}
|