|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+#include <debug.h>
|
|
|
2
|
+#include <cxxtest/TestSuite.h>
|
|
|
3
|
+
|
|
|
4
|
+class TestDebug : public CxxTest::TestSuite
|
|
|
5
|
+{
|
|
|
6
|
+public:
|
|
|
7
|
+ void setUp()
|
|
|
8
|
+ {
|
|
|
9
|
+ _at = 0;
|
|
|
10
|
+ }
|
|
|
11
|
+
|
|
|
12
|
+ void test_basic()
|
|
|
13
|
+ {
|
|
|
14
|
+ Debug::info("rock on!");
|
|
|
15
|
+ TS_ASSERT_EQUALS(0, strcmp("info: rock on!\r\n", _msg));
|
|
|
16
|
+ }
|
|
|
17
|
+
|
|
|
18
|
+ void test_signed()
|
|
|
19
|
+ {
|
|
|
20
|
+ Debug::info("decimal %d.", -1234);
|
|
|
21
|
+ TS_ASSERT_EQUALS(0, strcmp("info: decimal -1234.\r\n", _msg));
|
|
|
22
|
+ }
|
|
|
23
|
+
|
|
|
24
|
+ void test_unsigned()
|
|
|
25
|
+ {
|
|
|
26
|
+ Debug::info("unsigned %u.", -1234);
|
|
|
27
|
+ TS_ASSERT_EQUALS(0, strcmp("info: unsigned 4294966062.\r\n", _msg));
|
|
|
28
|
+ }
|
|
|
29
|
+
|
|
|
30
|
+ void test_hex()
|
|
|
31
|
+ {
|
|
|
32
|
+ Debug::info("hex %x.", 0xabcd5678);
|
|
|
33
|
+ TS_ASSERT_EQUALS(0, strcmp("info: hex abcd5678.\r\n", _msg));
|
|
|
34
|
+ }
|
|
|
35
|
+
|
|
|
36
|
+ void test_string()
|
|
|
37
|
+ {
|
|
|
38
|
+ Debug::info("str %s.", "rock on!");
|
|
|
39
|
+ TS_ASSERT_EQUALS(0, strcmp("info: str rock on!.\r\n", _msg));
|
|
|
40
|
+ }
|
|
|
41
|
+
|
|
|
42
|
+ static int _at;
|
|
|
43
|
+ static char _msg[128];
|
|
|
44
|
+};
|
|
|
45
|
+
|
|
|
46
|
+void Debug::putch(char ch)
|
|
|
47
|
+{
|
|
|
48
|
+ TestDebug::_msg[TestDebug::_at++] = ch;
|
|
|
49
|
+ TestDebug::_msg[TestDebug::_at] = '\0';
|
|
|
50
|
+}
|
|
|
51
|
+
|
|
|
52
|
+#ifdef CXXTEST_RUNNING
|
|
|
53
|
+int TestDebug::_at;
|
|
|
54
|
+char TestDebug::_msg[128];
|
|
|
55
|
+#endif
|