libpropeller
Making PropellerGCC Easier
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
stopwatch.test.h
Go to the documentation of this file.
1 #include "unity.h"
2 #include "stopwatch.h"
3 
4 unsigned int unit_CNT;
5 unsigned int unit_CLKFREQ = 80000000;
6 
7 class UnityTests{
8 public:
9 
10  static void setUp(void) {
11 
12  }
13 
14  static void tearDown(void) {
15 
16  }
17 
18  //TODO(SRLM): Add test for GetStarted();
19 
20  // -----------------------------------------------------------------------------
21 
22  static void test_short_basic_case(void) {
23  const int milliseconds = 10000;
24  unit_CNT = 0;
25  Stopwatch sw;
26  sw.Start();
27  unit_CNT = unit_CLKFREQ / 1000 * milliseconds;
28  TEST_ASSERT_EQUAL_INT(milliseconds, sw.GetElapsed());
29  }
30 
31  static void test_long_basic_case(void) {
32  const int milliseconds = 50000;
33  unit_CNT = 0;
34  Stopwatch sw;
35  sw.Start();
36  unit_CNT = unit_CLKFREQ / 1000 * milliseconds;
37  TEST_ASSERT_EQUAL_INT(milliseconds, sw.GetElapsed());
38  }
39 
40  static void test_short_rollover_case(void) {
41  const int milliseconds = 5000;
42  unit_CNT = 0xFfffFfff;
43  Stopwatch sw;
44  sw.Start();
45  unit_CNT = unit_CNT + unit_CLKFREQ / 1000 * milliseconds;
46  TEST_ASSERT_EQUAL_INT(milliseconds, sw.GetElapsed());
47  }
48 
49  static void test_long_rollover_case(void) {
50  const int milliseconds = 50000;
51  unit_CNT = 0xFfffFfff;
52  Stopwatch sw;
53  sw.Start();
54  unit_CNT = unit_CNT + unit_CLKFREQ / 1000 * milliseconds;
55  TEST_ASSERT_EQUAL_INT(milliseconds, sw.GetElapsed());
56  }
57 
58 };