diff options
Diffstat (limited to 'kbruch/testcases')
-rw-r--r-- | kbruch/testcases/primenumber_test.cpp | 52 | ||||
-rw-r--r-- | kbruch/testcases/ratio_test.cpp | 158 |
2 files changed, 105 insertions, 105 deletions
diff --git a/kbruch/testcases/primenumber_test.cpp b/kbruch/testcases/primenumber_test.cpp index c0e322fb..0a5ee2b6 100644 --- a/kbruch/testcases/primenumber_test.cpp +++ b/kbruch/testcases/primenumber_test.cpp @@ -36,52 +36,52 @@ class primenumber_test /** test the prime number algorithm */ void test_isPrimeNumber() { - BOOST_REQUIRE(m_primenumber.isPrimeNumber(0) == 0); - BOOST_REQUIRE(m_primenumber.isPrimeNumber(2) == 1); - BOOST_REQUIRE(m_primenumber.isPrimeNumber(3) == 1); - BOOST_REQUIRE(m_primenumber.isPrimeNumber(4) == 0); - BOOST_REQUIRE(m_primenumber.isPrimeNumber(5) == 1); - BOOST_REQUIRE(m_primenumber.isPrimeNumber(6) == 0); - BOOST_REQUIRE(m_primenumber.isPrimeNumber(7) == 1); - BOOST_REQUIRE(m_primenumber.isPrimeNumber(8) == 0); - BOOST_REQUIRE(m_primenumber.isPrimeNumber(9) == 0); - BOOST_REQUIRE(m_primenumber.isPrimeNumber(23) == 1); - BOOST_REQUIRE(m_primenumber.isPrimeNumber(9) == 0); - BOOST_REQUIRE(m_primenumber.isPrimeNumber(9) == 0); - BOOST_REQUIRE(m_primenumber.isPrimeNumber(6) == 0); - BOOST_REQUIRE(m_primenumber.isPrimeNumber(101) == 1); - BOOST_REQUIRE(m_primenumber.isPrimeNumber(323) == 0); // 17 * 19 - BOOST_REQUIRE(m_primenumber.isPrimeNumber(1001) == 0); // 7 * 143 - BOOST_REQUIRE(m_primenumber.isPrimeNumber(1002) == 0); // 2 * 501 - BOOST_REQUIRE(m_primenumber.isPrimeNumber(3) == 1); - BOOST_REQUIRE(m_primenumber.isPrimeNumber(2) == 1); + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(0) == 0); + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(2) == 1); + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(3) == 1); + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(4) == 0); + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(5) == 1); + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(6) == 0); + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(7) == 1); + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(8) == 0); + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(9) == 0); + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(23) == 1); + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(9) == 0); + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(9) == 0); + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(6) == 0); + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(101) == 1); + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(323) == 0); // 17 * 19 + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(1001) == 0); // 7 * 143 + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(1002) == 0); // 2 * 501 + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(3) == 1); + BOOST_RETQUIRE(m_primenumber.isPrimeNumber(2) == 1); } /** test the get_first() function */ void test_get_first() { - BOOST_REQUIRE(m_primenumber.get_first() == 2); + BOOST_RETQUIRE(m_primenumber.get_first() == 2); } /** test the move and get functions */ void test_move_get_func() { m_primenumber.move_first(); - BOOST_REQUIRE(m_primenumber.get_current() == 2); - BOOST_REQUIRE(m_primenumber.get_next() == 3); + BOOST_RETQUIRE(m_primenumber.get_current() == 2); + BOOST_RETQUIRE(m_primenumber.get_next() == 3); m_primenumber.move_forward(); - BOOST_REQUIRE(m_primenumber.get_current() == 5); + BOOST_RETQUIRE(m_primenumber.get_current() == 5); m_primenumber.move_back(); - BOOST_REQUIRE(m_primenumber.get_current() == 3); + BOOST_RETQUIRE(m_primenumber.get_current() == 3); unsigned int tmp = m_primenumber.get_last(); m_primenumber.move_last(); - BOOST_REQUIRE(m_primenumber.get_current() == tmp); + BOOST_RETQUIRE(m_primenumber.get_current() == tmp); m_primenumber.move_forward(); - BOOST_REQUIRE(m_primenumber.get_last() != tmp); + BOOST_RETQUIRE(m_primenumber.get_last() != tmp); } private: diff --git a/kbruch/testcases/ratio_test.cpp b/kbruch/testcases/ratio_test.cpp index bdc4419b..0dac9dfe 100644 --- a/kbruch/testcases/ratio_test.cpp +++ b/kbruch/testcases/ratio_test.cpp @@ -38,29 +38,29 @@ class ratio_test { // check basic initialisation ratio * ratio_a = new ratio(); - BOOST_REQUIRE(ratio_a->numerator() == 0); - BOOST_REQUIRE(ratio_a->denominator() == 1); + BOOST_RETQUIRE(ratio_a->numerator() == 0); + BOOST_RETQUIRE(ratio_a->denominator() == 1); // a denominator with value 0 is never allowed ratio * ratio_b = new ratio(2, 0); - BOOST_REQUIRE(ratio_b->numerator() == 2); - BOOST_REQUIRE(ratio_b->denominator() == 1); // division by zero not allowed + BOOST_RETQUIRE(ratio_b->numerator() == 2); + BOOST_RETQUIRE(ratio_b->denominator() == 1); // division by zero not allowed // a new ratio should always be reduced ratio * ratio_c = new ratio(2, 4); - BOOST_REQUIRE(ratio_c->numerator() == 1); - BOOST_REQUIRE(ratio_c->denominator() == 2); + BOOST_RETQUIRE(ratio_c->numerator() == 1); + BOOST_RETQUIRE(ratio_c->denominator() == 2); // check copy constructor ratio * ratio_d = new ratio(*ratio_c); - BOOST_REQUIRE(ratio_d->numerator() == 1); - BOOST_REQUIRE(ratio_d->denominator() == 2); + BOOST_RETQUIRE(ratio_d->numerator() == 1); + BOOST_RETQUIRE(ratio_d->denominator() == 2); // the copy constructor is not allowed to reduce the new ratio ratio_d->setNumerator(4, false); ratio * ratio_e = new ratio(*ratio_d); - BOOST_REQUIRE(ratio_e->numerator() == 4); - BOOST_REQUIRE(ratio_e->denominator() == 2); + BOOST_RETQUIRE(ratio_e->numerator() == 4); + BOOST_RETQUIRE(ratio_e->denominator() == 2); delete(ratio_a); delete(ratio_b); @@ -77,33 +77,33 @@ class ratio_test // check setNumerator() and numerator() (get) ratio * ratio_a = new ratio(); ratio_a->setNumerator(10); - BOOST_REQUIRE(ratio_a->numerator() == 10); - BOOST_REQUIRE(ratio_a->denominator() == 1); + BOOST_RETQUIRE(ratio_a->numerator() == 10); + BOOST_RETQUIRE(ratio_a->denominator() == 1); // check setDenominator() and denominator() (get) ratio_a->setDenominator(7); - BOOST_REQUIRE(ratio_a->numerator() == 10); - BOOST_REQUIRE(ratio_a->denominator() == 7); + BOOST_RETQUIRE(ratio_a->numerator() == 10); + BOOST_RETQUIRE(ratio_a->denominator() == 7); // now check if the ratio gets reduced ratio_a->setNumerator(14); - BOOST_REQUIRE(ratio_a->numerator() == 2); - BOOST_REQUIRE(ratio_a->denominator() == 1); + BOOST_RETQUIRE(ratio_a->numerator() == 2); + BOOST_RETQUIRE(ratio_a->denominator() == 1); // lets do the same, but with out reducing ratio_a->setNumerator(14, false); ratio_a->setDenominator(7, false); - BOOST_REQUIRE(ratio_a->numerator() == 14); - BOOST_REQUIRE(ratio_a->denominator() == 7); + BOOST_RETQUIRE(ratio_a->numerator() == 14); + BOOST_RETQUIRE(ratio_a->denominator() == 7); // now the = operator ratio * ratio_b = new ratio(); *ratio_b = *ratio_a; - BOOST_REQUIRE(ratio_b->numerator() == 14); - BOOST_REQUIRE(ratio_b->denominator() == 7); + BOOST_RETQUIRE(ratio_b->numerator() == 14); + BOOST_RETQUIRE(ratio_b->denominator() == 7); // make sure we didn't just copied the pointers - BOOST_REQUIRE(ratio_a != ratio_b); + BOOST_RETQUIRE(ratio_a != ratio_b); delete(ratio_a); delete(ratio_b); @@ -116,13 +116,13 @@ class ratio_test { ratio ratio_a; ratio_a = 8; - BOOST_REQUIRE(ratio_a.numerator() == 8); - BOOST_REQUIRE(ratio_a.denominator() == 1); + BOOST_RETQUIRE(ratio_a.numerator() == 8); + BOOST_RETQUIRE(ratio_a.denominator() == 1); ratio ratio_b(2, 3); ratio_a = ratio_b; - BOOST_REQUIRE(ratio_a.numerator() == 2); - BOOST_REQUIRE(ratio_a.denominator() == 3); + BOOST_RETQUIRE(ratio_a.numerator() == 2); + BOOST_RETQUIRE(ratio_a.denominator() == 3); return; } @@ -140,29 +140,29 @@ class ratio_test // check + operator ratio ratio_c = *ratio_a + *ratio_b; - BOOST_REQUIRE(ratio_c.numerator() == 5); - BOOST_REQUIRE(ratio_c.denominator() == 2); + BOOST_RETQUIRE(ratio_c.numerator() == 5); + BOOST_RETQUIRE(ratio_c.denominator() == 2); // it should be the same if we change the addends ratio_c = *ratio_b + *ratio_a; - BOOST_REQUIRE(ratio_c.numerator() == 5); - BOOST_REQUIRE(ratio_c.denominator() == 2); + BOOST_RETQUIRE(ratio_c.numerator() == 5); + BOOST_RETQUIRE(ratio_c.denominator() == 2); // check - operator ratio_c = *ratio_b - *ratio_a; - BOOST_REQUIRE(ratio_c.numerator() == -3); - BOOST_REQUIRE(ratio_c.denominator() == 2); + BOOST_RETQUIRE(ratio_c.numerator() == -3); + BOOST_RETQUIRE(ratio_c.denominator() == 2); // it should not be the same if we change the subtrahends ratio_c = *ratio_a - *ratio_b; - BOOST_REQUIRE(ratio_c.numerator() == 3); - BOOST_REQUIRE(ratio_c.denominator() == 2); + BOOST_RETQUIRE(ratio_c.numerator() == 3); + BOOST_RETQUIRE(ratio_c.denominator() == 2); // now check if we can get 0/1 *ratio_a = *ratio_b; ratio_c = *ratio_a - *ratio_b; - BOOST_REQUIRE(ratio_c.numerator() == 0); - BOOST_REQUIRE(ratio_c.denominator() == 1); + BOOST_RETQUIRE(ratio_c.numerator() == 0); + BOOST_RETQUIRE(ratio_c.denominator() == 1); delete(ratio_a); delete(ratio_b); @@ -183,32 +183,32 @@ class ratio_test // check * operator ratio ratio_c = *ratio_a * *ratio_b; - BOOST_REQUIRE(ratio_c.numerator() == 1); - BOOST_REQUIRE(ratio_c.denominator() == 2); + BOOST_RETQUIRE(ratio_c.numerator() == 1); + BOOST_RETQUIRE(ratio_c.denominator() == 2); // it should be the same if we change the addends ratio_c = *ratio_b * *ratio_a; - BOOST_REQUIRE(ratio_c.numerator() == 1); - BOOST_REQUIRE(ratio_c.denominator() == 2); + BOOST_RETQUIRE(ratio_c.numerator() == 1); + BOOST_RETQUIRE(ratio_c.denominator() == 2); // check / operator ratio_c = *ratio_b / *ratio_a; - BOOST_REQUIRE(ratio_c.numerator() == 1); - BOOST_REQUIRE(ratio_c.denominator() == 8); + BOOST_RETQUIRE(ratio_c.numerator() == 1); + BOOST_RETQUIRE(ratio_c.denominator() == 8); // it should not be the same if we change the subtrahends ratio_c = *ratio_a / *ratio_b; - BOOST_REQUIRE(ratio_c.numerator() == 8); - BOOST_REQUIRE(ratio_c.denominator() == 1); + BOOST_RETQUIRE(ratio_c.numerator() == 8); + BOOST_RETQUIRE(ratio_c.denominator() == 1); // now check if we can get 0/1 *ratio_a = 0; ratio_c = *ratio_a * *ratio_b; - BOOST_REQUIRE(ratio_c.numerator() == 0); - BOOST_REQUIRE(ratio_c.denominator() == 1); + BOOST_RETQUIRE(ratio_c.numerator() == 0); + BOOST_RETQUIRE(ratio_c.denominator() == 1); ratio_c = *ratio_a / *ratio_b; - BOOST_REQUIRE(ratio_c.numerator() == 0); - BOOST_REQUIRE(ratio_c.denominator() == 1); + BOOST_RETQUIRE(ratio_c.numerator() == 0); + BOOST_RETQUIRE(ratio_c.denominator() == 1); delete(ratio_a); delete(ratio_b); @@ -221,8 +221,8 @@ class ratio_test { ratio ratio_a(2, 3); ratio_a.reziproc(); - BOOST_REQUIRE(ratio_a.numerator() == 3); - BOOST_REQUIRE(ratio_a.denominator() == 2); + BOOST_RETQUIRE(ratio_a.numerator() == 3); + BOOST_RETQUIRE(ratio_a.denominator() == 2); return; } @@ -234,8 +234,8 @@ class ratio_test ratio_a.setNumerator(51, false); ratio_a.setDenominator(17, false); ratio_a.reduce(); - BOOST_REQUIRE(ratio_a.numerator() == 3); - BOOST_REQUIRE(ratio_a.denominator() == 1); + BOOST_RETQUIRE(ratio_a.numerator() == 3); + BOOST_RETQUIRE(ratio_a.denominator() == 1); return; } @@ -249,11 +249,11 @@ class ratio_test ratio ratio_d(2, -3); ratio ratio_e(-2, 3); - BOOST_REQUIRE((ratio_a == ratio_a) == true); - BOOST_REQUIRE((ratio_a == ratio_b) == true); - BOOST_REQUIRE((ratio_a == ratio_c) == true); - BOOST_REQUIRE((ratio_a == ratio_d) == false); - BOOST_REQUIRE((ratio_a == ratio_e) == false); + BOOST_RETQUIRE((ratio_a == ratio_a) == true); + BOOST_RETQUIRE((ratio_a == ratio_b) == true); + BOOST_RETQUIRE((ratio_a == ratio_c) == true); + BOOST_RETQUIRE((ratio_a == ratio_d) == false); + BOOST_RETQUIRE((ratio_a == ratio_e) == false); return; } @@ -267,21 +267,21 @@ class ratio_test ratio ratio_d(2, -3); ratio ratio_e(-2, 3); - BOOST_REQUIRE((ratio_a < ratio_a) == false); - BOOST_REQUIRE((ratio_a < ratio_b) == false); - BOOST_REQUIRE((ratio_a < ratio_c) == false); - BOOST_REQUIRE((ratio_a < ratio_d) == false); - BOOST_REQUIRE((ratio_a < ratio_e) == false); + BOOST_RETQUIRE((ratio_a < ratio_a) == false); + BOOST_RETQUIRE((ratio_a < ratio_b) == false); + BOOST_RETQUIRE((ratio_a < ratio_c) == false); + BOOST_RETQUIRE((ratio_a < ratio_d) == false); + BOOST_RETQUIRE((ratio_a < ratio_e) == false); ratio_a = ratio(-2, 3); - BOOST_REQUIRE((ratio_a < ratio_a) == false); - BOOST_REQUIRE((ratio_a < ratio_b) == true); - BOOST_REQUIRE((ratio_a < ratio_c) == true); - BOOST_REQUIRE((ratio_a < ratio_d) == false); - BOOST_REQUIRE((ratio_a < ratio_e) == false); + BOOST_RETQUIRE((ratio_a < ratio_a) == false); + BOOST_RETQUIRE((ratio_a < ratio_b) == true); + BOOST_RETQUIRE((ratio_a < ratio_c) == true); + BOOST_RETQUIRE((ratio_a < ratio_d) == false); + BOOST_RETQUIRE((ratio_a < ratio_e) == false); - BOOST_REQUIRE((ratio(5, 8) < ratio(2, 1)) == true); + BOOST_RETQUIRE((ratio(5, 8) < ratio(2, 1)) == true); return; } @@ -296,21 +296,21 @@ class ratio_test ratio ratio_e(-2, 3); ratio ratio_f(-4, 3); - BOOST_REQUIRE((ratio_a > ratio_a) == false); - BOOST_REQUIRE((ratio_a > ratio_b) == false); - BOOST_REQUIRE((ratio_a > ratio_c) == false); - BOOST_REQUIRE((ratio_a > ratio_d) == true); - BOOST_REQUIRE((ratio_a > ratio_e) == true); - BOOST_REQUIRE((ratio_a > ratio_f) == true); + BOOST_RETQUIRE((ratio_a > ratio_a) == false); + BOOST_RETQUIRE((ratio_a > ratio_b) == false); + BOOST_RETQUIRE((ratio_a > ratio_c) == false); + BOOST_RETQUIRE((ratio_a > ratio_d) == true); + BOOST_RETQUIRE((ratio_a > ratio_e) == true); + BOOST_RETQUIRE((ratio_a > ratio_f) == true); ratio_a = ratio(-2, 3); - BOOST_REQUIRE((ratio_a > ratio_a) == false); - BOOST_REQUIRE((ratio_a > ratio_b) == false); - BOOST_REQUIRE((ratio_a > ratio_c) == false); - BOOST_REQUIRE((ratio_a > ratio_d) == false); - BOOST_REQUIRE((ratio_a > ratio_e) == false); - BOOST_REQUIRE((ratio_a > ratio_f) == true); + BOOST_RETQUIRE((ratio_a > ratio_a) == false); + BOOST_RETQUIRE((ratio_a > ratio_b) == false); + BOOST_RETQUIRE((ratio_a > ratio_c) == false); + BOOST_RETQUIRE((ratio_a > ratio_d) == false); + BOOST_RETQUIRE((ratio_a > ratio_e) == false); + BOOST_RETQUIRE((ratio_a > ratio_f) == true); return; } |