Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This section is basically the same in terms of test suites as in the Calculator project, but was not covered on the previous page.

Inside the tst directory in test_operation.cpp the following test suites can be found:

Code Block
languagecpp
titleTEST(DivideOperation, PositiveInput)
linenumberstrue
TEST(DivideOperation, PositiveInput) {
    // Integer arguments
    ASSERT_EQ(divide(10, 5), 2);
    ASSERT_FLOAT_EQ(divide(5, 10), 0.5);
    // Floating-point arguments
    ASSERT_FLOAT_EQ(divide(10.0f, 5.0f), 2.0f);
    ASSERT_FLOAT_EQ(divide(5.0f, 10.0f), 0.5f);
}


Code Block
languagecpp
titleTEST(DivideOperation, NegitiveInput)
linenumberstrue
TEST(DivideOperation, NegitiveInput) {
    ASSERT_EQ(divide(-10, -5), 2);
    ASSERT_FLOAT_EQ(divide(-5, -10), 0.5);
    // Floating-point arguments
    ASSERT_FLOAT_EQ(divide(-10.0f, -5.0f), 2.0f);
    ASSERT_FLOAT_EQ(divide(-5.0f, -10.0f), 0.5f);
}


Code Block
languagecpp
titleTEST(DivideOperation, ZerioInput)
linenumberstrue
TEST(DivideOperation, ZerioInput) {
    EXPECT_THROW(divide(10, 0), std::overflow_error);
    EXPECT_THROW(divide(10.0f, 0.0f), std::overflow_error);
}


2. Testing whether the result is within range

...