| 15 | using namespace CoreML; |
| 16 | |
| 17 | int testRangeVal() { |
| 18 | |
| 19 | // Unbound constructor |
| 20 | RangeValue test1 = RangeValue(); |
| 21 | ML_ASSERT(test1.isUnbound()); |
| 22 | |
| 23 | // Relations between set and unbound |
| 24 | RangeValue test2 = RangeValue(2); |
| 25 | ML_ASSERT(test1 > test2); |
| 26 | ML_ASSERT(test1 >= test2); |
| 27 | ML_ASSERT(test2 < test1); |
| 28 | ML_ASSERT(test2 <= test1); |
| 29 | |
| 30 | ML_ASSERT(test1 > 2); |
| 31 | ML_ASSERT(test1 >= 2); |
| 32 | |
| 33 | ML_ASSERT(!(test1 < 6)); |
| 34 | ML_ASSERT(!(test1 <= 6)); |
| 35 | |
| 36 | // Relations between two set values |
| 37 | RangeValue test3 = RangeValue(3); |
| 38 | ML_ASSERT(test3 > test2); |
| 39 | ML_ASSERT(test3 >= test2); |
| 40 | ML_ASSERT(test2 < test3); |
| 41 | ML_ASSERT(test2 <= test3); |
| 42 | |
| 43 | ML_ASSERT(test2 < 3); |
| 44 | ML_ASSERT(test2 <= 3); |
| 45 | ML_ASSERT(test2 > 1); |
| 46 | ML_ASSERT(test2 >= 1); |
| 47 | ML_ASSERT(test2 >= 2); |
| 48 | |
| 49 | |
| 50 | // Test two unbound values |
| 51 | RangeValue test4 = RangeValue(); |
| 52 | ML_ASSERT(test4 > test1); |
| 53 | ML_ASSERT(test1 > test4); |
| 54 | ML_ASSERT(!(test4 < test1)); |
| 55 | ML_ASSERT(!(test1 < test4)); |
| 56 | |
| 57 | ML_ASSERT(test4 >= test1); |
| 58 | ML_ASSERT(test1 >= test4); |
| 59 | ML_ASSERT(test4 <= test1); |
| 60 | ML_ASSERT(test1 <= test4); |
| 61 | |
| 62 | |
| 63 | ML_ASSERT(test2.value() == 2); |
| 64 | bool catch_me = false; |
| 65 | try { |
| 66 | test1.value(); |
| 67 | ML_ASSERT(0); |
| 68 | } |
| 69 | catch (std::runtime_error& err) { |
| 70 | // this should throw, so we're ok -- this is a pass |
| 71 | ML_ASSERT(1); |
| 72 | catch_me = true; |
| 73 | } |
| 74 | ML_ASSERT(catch_me); |
nothing calls this directly
no test coverage detected