libpropeller
Making PropellerGCC Easier
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
pin.test.h
Go to the documentation of this file.
1 #include "unity.h"
2 #include "c++-alloc.h"
3 #include "libpropeller/pin/pin.h"
4 
5 #include "libpropeller/board/board_unit_tester.h"
6 
7 
8 Pin * a = NULL;
9 Pin * b = NULL;
10 
11 class UnityTests {
12 public:
13 
14  static void setUp(void) {
15  a = new Pin(Board::kPinTie1a);
16  b = new Pin(Board::kPinTie1b);
17  }
18 
19  static void tearDown(void) {
20  delete a;
21  delete b;
22  a = b = NULL;
23  }
24 
25  static void test_HighLow(void) {
26  a->high();
27  TEST_ASSERT_EQUAL_INT(1, b->input());
28 
29  a->low();
30  TEST_ASSERT_EQUAL_INT(0, b->input());
31  }
32 
33  static void test_Toggle(void) {
34  a->high();
35  int output = 1;
36  for (int i = 0; i < 100; i++) {
37  a->toggle();
38  output = output == 1 ? 0 : 1;
39  TEST_ASSERT_EQUAL_INT(output, b->input());
40  }
41  }
42 
43  static void test_isOutput(void) {
44  a->input();
45  TEST_ASSERT_FALSE(a->isOutput());
46 
47  a->high();
48  TEST_ASSERT_TRUE(a->isOutput());
49  }
50 
51  static void test_Ouput(void) {
52  a->output(1);
53  TEST_ASSERT_EQUAL_INT(1, b->input());
54 
55  a->output(0);
56  TEST_ASSERT_EQUAL_INT(0, b->input());
57  }
58 
59 };