Question: How would the rules in the below Makefile be written for the below c++ test case? fill the section that says # Need a rule
How would the rules in the below Makefile be written for the below c++ test case? fill the section that says "# Need a rule to build objects"
| //Test case | |
| #define CATCH_CONFIG_MAIN | |
| #include | |
| #include "catch/catch.hpp" | |
| #include "../foo.hpp" | |
| #include "../bar.hpp" | |
| #include "../baz.hpp" | |
| TEST_CASE("Test Classes. PASS.") | |
| { | |
| REQUIRE (Foo.GetMagicNumber() == 12); | |
| Bar b = Bar("Hello"); | |
| REQUIRE (b.GetString() == "Hello"); | |
| Baz *baz = new Baz(90.0 / 9); | |
| REQUIRE (baz->GetValue() > 9.999 && baz->GetValue() < 10.0001); | |
| } | |
| // Compile & run: | |
| // make clean test |
| //Makefile | |
| CXX = g++ | |
| CXXFLAGS = -std=c++11 -Wall | |
| OBJECTS = # list of .o files. One for each class | |
| # Need a rule to build objects | |
| testBuild: main | |
| $(CXX) $(CXXFLAGS) -Itest/catch/catch.hpp -o test/TestCase $(OBJECTS) test/TestCase.cpp | |
| test: clean testBuild | |
| test/TestCase --success | |
| clean: | |
| $(RM) *.o *.gch main test/TestCase |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
