// // bound_number.t.h // limit // // Created by Sam Jaffe on 2/3/17. // #pragma once #include "bound_number.hpp" #include class bound_number_TestSuite : public CxxTest::TestSuite { public: using number_t = bound_number; // Fails to compile because of well-ordered principle // void test_bounds_compiler_error() { // bound_number(0); // } void test_number_construct_inbounds() { number_t n{0}; TS_ASSERT_EQUALS(n, 0); } void test_number_validate_oob_low() { TS_ASSERT_THROWS((number_t{check_bounds, -6}), std::out_of_range); } void test_number_validate_oob_high() { TS_ASSERT_THROWS((number_t{check_bounds, +8}), std::out_of_range); } void test_number_cannot_construct_oob_low() { number_t n{-6}; TS_ASSERT_EQUALS(n, number_t::min); } void test_number_cannot_construct_oob_high() { number_t n{10}; TS_ASSERT_EQUALS(n, number_t::max); } void test_number_cannot_increment_above_limit() { number_t n{+7}; TS_ASSERT_EQUALS(n++, number_t::max); TS_ASSERT_EQUALS(n, number_t::max); } void test_number_cannot_decrement_below_limit() { number_t n{-5}; TS_ASSERT_EQUALS(n--, number_t::min); TS_ASSERT_EQUALS(n, number_t::min); } };