Skip to content

4. Unit Tests

Jinfeng-Lyu edited this page Apr 13, 2023 · 39 revisions
  1. Unit Tests

In this section, we use googletest as the tool of unit test. The source is from this website: https://github.com/google/googletest. The function of googletest is to use assertions to check whether the output value of a programme is corresponded to the expected value. If does not correspond, the system will report a failure. There are two kinds of assertions, namely ASSERT and EXPECT. The former can produce a serious failure if detects an error in the programme, then stop the running of the programme. The latter can generate a slight failure and do not stop the program even if a mistake detected.

The commands in googletest are as follow: ASSERT_TRUE(condition_1), or EXPECT_TURE(condition_1): judge whether condition_1 is true. ASSERT_EQ(expected_value_1,actual_value_1), or EXPECT_EQ(expected_value_1,actual_value_1): judge whether actual_value_1 equals to expected_value_1. ASSERT_NE(expected_value_2,actual_value_2), or EXPECT_NE(expected_value_2,actual_value_2): judge whether actual_value_2 inequals to expected_value_2.

Clone this wiki locally