Testing
Writing automated tests with GoogleTest
Let me cut down this test for you
#include "../src/super-math.h"
#include <gtest/gtest.h>
TEST(DoubleMeSuite, DoubleMePositiveValues) {
EXPECT_EQ(double_me(23), 46);
}
#include "../src/super-math.h"we include the header file containing the function we want to test#include <gtest/gtest.h>we include gtest header to access to their macrosTEST(DoubleMeSuite, DoubleMePositiveValues) { ... }TESTis a macro to define a test case, the first argument is the name of the suite, the second is the name of the test. You will have several tests per suite but the second parameter will be unique.EXPECT_EQis another macro that let you verify that the first value returned by the tested function is the same as the second argumentASSERT_EQis doing the same but it will stop the current test if it fails, so you will see only one error
You can read more on the GoogleTest documentation how to write more advanced tests.
TODO: continue with more assertions...