16
16
#include < utility> // std::pair
17
17
#include " mbed.h"
18
18
#include " greentea-client/test_env.h"
19
+ #include " utest/utest.h"
20
+ #include " unity/unity.h"
21
+
22
+ using utest::v1::Case;
23
+
24
+ static const int test_timeout = 5 ;
19
25
20
26
uint32_t test_64 (uint64_t ticks)
21
27
{
@@ -28,34 +34,42 @@ uint32_t test_64(uint64_t ticks)
28
34
return (uint32_t )(0xFFFFFFFF & ticks);
29
35
}
30
36
31
- const char *result_str (bool result)
32
- {
33
- return result ? " [OK]" : " [FAIL]" ;
34
- }
35
37
36
- int main ( )
38
+ void test_division ( void )
37
39
{
38
- GREENTEA_SETUP (5 , " default_auto" );
39
-
40
- bool result = true ;
41
40
42
41
{
43
42
// 0xFFFFFFFF * 8 = 0x7fffffff8
44
43
std::pair<uint32_t , uint64_t > values = std::make_pair (0x55555555 , 0x7FFFFFFF8 );
45
44
uint32_t test_ret = test_64 (values.second );
46
- bool test_res = values.first == test_ret;
47
- result = result && test_res;
48
- printf (" 64bit: 0x7FFFFFFF8: expected 0x%lX got 0x%lX ... %s\r\n " , values.first , test_ret, result_str (test_res));
45
+ utest_printf (" 64bit: 0x7FFFFFFF8: expected 0x%lX got 0x%lX \r\n " , values.first , test_ret);
46
+ TEST_ASSERT_EQUAL_UINT32 (values.first , test_ret);
49
47
}
50
48
51
49
{
52
50
// 0xFFFFFFFF * 24 = 0x17ffffffe8
53
51
std::pair<uint32_t , uint64_t > values = std::make_pair (0xFFFFFFFF , 0x17FFFFFFE8 );
54
52
uint32_t test_ret = test_64 (values.second );
55
- bool test_res = values.first == test_ret;
56
- result = result && test_res;
57
- printf (" 64bit: 0x17FFFFFFE8: expected 0x%lX got 0x%lX ... %s\r\n " , values.first , test_ret, result_str (test_res));
53
+ utest_printf (" 64bit: 0x17FFFFFFE8: expected 0x%lX got 0x%lX \r\n " , values.first , test_ret);
54
+ TEST_ASSERT_EQUAL_UINT32 (values.first , test_ret);
58
55
}
59
56
60
- GREENTEA_TESTSUITE_RESULT (result);
57
+ }
58
+
59
+ // Test cases
60
+ Case cases[] = {
61
+ Case (" Test division" , test_division),
62
+ };
63
+
64
+ utest::v1::status_t greentea_test_setup (const size_t number_of_cases)
65
+ {
66
+ GREENTEA_SETUP (test_timeout, " default_auto" );
67
+ return utest::v1::greentea_test_setup_handler (number_of_cases);
68
+ }
69
+
70
+ utest::v1::Specification specification (greentea_test_setup, cases);
71
+
72
+ int main ()
73
+ {
74
+ return !utest::v1::Harness::run (specification);
61
75
}
0 commit comments