Bruno Allaire-Lemay
/
APP1test
df
Fork of APP1 by
Diff: TestUtility.cpp
- Revision:
- 12:1c341b119b23
- Parent:
- 9:12519f9dd3cd
- Child:
- 13:bb9669053eb3
--- a/TestUtility.cpp Sun Jan 15 18:57:53 2017 +0000 +++ b/TestUtility.cpp Sun Jan 15 19:46:10 2017 +0000 @@ -10,6 +10,8 @@ test_is_almost_equal(); test_degree_from_radian(); test_wrap_angle(); + test_update_bit(); + test_update_bit_for_values_greater_than_one_byte(); } void test_is_almost_equal() @@ -41,4 +43,19 @@ assert(is_almost_equal(90, wrap_angle(360+90), tolerance)); assert(is_almost_equal(270, wrap_angle(360-90), tolerance)); } + + void test_update_bit() + { + assert(4 == sizeof(int)); + assert(0x00 == update_bit(0x00, 0, 0)); + assert(0x01 == update_bit(0x00, 0, 1)); + assert(0x00 == update_bit(0x01, 0, 0)); + assert(0x05 == update_bit(0x07, 1, 0)); + } + + void test_update_bit_for_values_greater_than_one_byte() + { + assert(0x7FFF == update_bit(0xFFFF, 15, 0)); + assert(0x7FFFFFFF == update_bit(0xFFFFFFFF, 31, 0)); + } } \ No newline at end of file