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
|
#include "vendor/unity.h"
#include "../src/resistor_color.h"
#define ARRAY_LENGTH(A) (sizeof(A) / sizeof(A[0]))
void setUp(void)
{
}
void tearDown(void)
{
}
static void test_black(void)
{
TEST_ASSERT_EQUAL_UINT16(0, color_code(BLACK));
}
static void test_white(void)
{
TEST_ASSERT_EQUAL_UINT16(9, color_code(WHITE));
}
static void test_orange(void)
{
TEST_ASSERT_EQUAL_UINT16(3, color_code(ORANGE));
}
static void test_colors(void)
{
const resistor_band_t expected[] = {
BLACK, BROWN, RED, ORANGE, YELLOW,
GREEN, BLUE, VIOLET, GREY, WHITE
};
TEST_ASSERT_EQUAL_INT_ARRAY(expected, colors(), ARRAY_LENGTH(expected));
}
int main(void)
{
UnityBegin("test/test_resistor_color.c");
RUN_TEST(test_black);
RUN_TEST(test_white);
RUN_TEST(test_orange);
RUN_TEST(test_colors);
return UnityEnd();
}
|