aboutsummaryrefslogtreecommitdiff
path: root/test/lib/color.c
blob: 191972d1941e97ecebc0fdbf2454d4b1c7b6d9a9 (plain)
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
#include <test/lib/color.h>

bool_t test_color_zero(uint8_t* color1, size_t channels, bool_t result)
{
  bool_t fcall_result = color_zero(color1, channels);
  if (fcall_result == result) {
    return TRUE;
  }
  return FALSE;
}
bool_t test_color_equal(uint8_t* color1, uint8_t* color2, size_t channels, bool_t result)
{
  bool_t fcall_result = color_zero(color1, channels);
  if (fcall_result == result) {
    return TRUE;
  }
  return FALSE;
}

// Meta test function
bool_t TEST_lib_color()
{
  uint8_t test_count = 0;
  uint8_t test_pass = 0;
  bool_t result;

  // Test 1: 1 channel zero color
  //  Should result: True
  uint8_t test_1_color1[1] = {0};
  result = test_color_zero(test_1_color1, 1, TRUE);
  TEST_RESULT(result, test_count, test_pass);

  // Test 2: 1 channel non-zero color
  //  Should result: False
  uint8_t test_2_color1[1] = {1};
  result = test_color_zero(test_2_color1, 1, FALSE);
  TEST_RESULT(result, test_count, test_pass);

  // Test 3: 2 channel zero color
  //  Should result: True
  uint8_t test_3_color1[2] = {0,0};
  result = test_color_zero(test_3_color1, 2, TRUE);
  TEST_RESULT(result, test_count, test_pass);

  // Test 4: 2 channel non-zero color
  //  Should result: False
  uint8_t test_4_color1[2] = {0,1};
  result = test_color_zero(test_4_color1, 2, FALSE);
  TEST_RESULT(result, test_count, test_pass);

  return test_count == test_pass;
}