-
Notifications
You must be signed in to change notification settings - Fork 3
4. Unit Tests
- 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. ASSERT_LT(expected_value_3,actual_value_3), or EXPECT_LT(expected_value_3,actual_value_3): judge whether actual_value_3 less than expected_value_3. ASSERT_LE(expected_value_4,actual_value_4), or EXPECT_LE(expected_value_4,actual_value_4): judge whether actual_value_4 less than or equal to expected_value_4. ASSERT_GT(expected_value_5,actual_value_5), or EXPECT_GT(expected_value_5,actual_value_5): judge whether actual_value_5 less than expected_value_5. ASSERT_GE(expected_value_6,actual_value_6), or EXPECT_GE(expected_value_6,actual_value_6): judge whether actual_value_6 less than or equal to expected_value_6.