21 SECTION(
"int32_t -> uint8_t") {
22 CHECK_NOTHROW(
test_narrow(int32_t( 0), uint8_t( 0)));
23 CHECK_NOTHROW(
test_narrow(int32_t( 100), uint8_t(100)));
24 CHECK_NOTHROW(
test_narrow(int32_t( 200), uint8_t(200)));
25 CHECK_NOTHROW(
test_narrow(int32_t( 255), uint8_t(255)));
27 CHECK_THROWS (
test_narrow(int32_t(-999), uint8_t(ERR)));
28 CHECK_THROWS (
test_narrow(int32_t(-256), uint8_t(ERR)));
29 CHECK_THROWS (
test_narrow(int32_t(-255), uint8_t(ERR)));
30 CHECK_THROWS (
test_narrow(int32_t( -1), uint8_t(ERR)));
31 CHECK_THROWS (
test_narrow(int32_t( 256), uint8_t(ERR)));
32 CHECK_THROWS (
test_narrow(int32_t( 300), uint8_t(ERR)));
33 CHECK_THROWS (
test_narrow(int32_t(9999), uint8_t(ERR)));
35 SECTION(
"int32_t -> int8_t") {
36 CHECK_NOTHROW(
test_narrow(int32_t(-128), int8_t(-128)));
37 CHECK_NOTHROW(
test_narrow(int32_t( -32), int8_t( -32)));
38 CHECK_NOTHROW(
test_narrow(int32_t( 0), int8_t( 0)));
39 CHECK_NOTHROW(
test_narrow(int32_t( 7), int8_t( 7)));
40 CHECK_NOTHROW(
test_narrow(int32_t( 100), int8_t( 100)));
41 CHECK_NOTHROW(
test_narrow(int32_t( 127), int8_t( 127)));
43 CHECK_THROWS (
test_narrow(int32_t(-999), int8_t(ERR)));
44 CHECK_THROWS (
test_narrow(int32_t(-456), int8_t(ERR)));
45 CHECK_THROWS (
test_narrow(int32_t(-129), int8_t(ERR)));
46 CHECK_THROWS (
test_narrow(int32_t( 128), int8_t(ERR)));
47 CHECK_THROWS (
test_narrow(int32_t( 356), int8_t(ERR)));
48 CHECK_THROWS (
test_narrow(int32_t(9999), int8_t(ERR)));
50 SECTION(
"uint32_t -> uint8_t") {
51 CHECK_NOTHROW(
test_narrow(uint32_t( 0), uint8_t( 0)));
52 CHECK_NOTHROW(
test_narrow(uint32_t( 100), uint8_t(100)));
53 CHECK_NOTHROW(
test_narrow(uint32_t( 200), uint8_t(200)));
54 CHECK_NOTHROW(
test_narrow(uint32_t( 255), uint8_t(255)));
56 CHECK_THROWS (
test_narrow(uint32_t( 256), uint8_t(ERR)));
57 CHECK_THROWS (
test_narrow(uint32_t( 300), uint8_t(ERR)));
58 CHECK_THROWS (
test_narrow(uint32_t(9999), uint8_t(ERR)));
60 SECTION(
"uint32_t -> int8_t") {
61 CHECK_NOTHROW(
test_narrow(uint32_t( 0), int8_t( 0)));
62 CHECK_NOTHROW(
test_narrow(uint32_t( 7), int8_t( 7)));
63 CHECK_NOTHROW(
test_narrow(uint32_t( 100), int8_t( 100)));
64 CHECK_NOTHROW(
test_narrow(uint32_t( 127), int8_t( 127)));
66 CHECK_THROWS (
test_narrow(uint32_t( 128), int8_t(ERR)));
67 CHECK_THROWS (
test_narrow(uint32_t( 356), int8_t(ERR)));
68 CHECK_THROWS (
test_narrow(uint32_t(9999), int8_t(ERR)));