small medium large xlarge

Paul-solt-square-march-2015-100x100_pragsmall
21 Mar 2017, 11:03
Paul Solt (1 post)

I had trouble building Chapter 5 (c5/1) on macOS, here are some notes:

  1. Fixed build failures from Google Mock 1.8.0 collection IsEmpty

AddressExtractorTest.cpp:15:1: Reference to ‘IsEmptyMatcher’ is ambiguous googletest-release-1.8.0/googlemock/include/gmock/gmock-generated-matchers.h:1419:10: Expanded from macro ‘MATCHER’ AddressExtractorTest.cpp:15:1: Candidate found by name lookup is ‘IsEmptyMatcher’ googletest-release-1.8.0/googlemock/include/gmock/gmock-more-matchers.h:48:1: Candidate found by name lookup is ‘testing::IsEmptyMatcher’

Solution

--- a/AddressExtractorTest.cpp
+++ b/AddressExtractorTest.cpp
@@ -12,7 +12,7 @@ public:
    AddressExtractor extractor;
 };
 
-MATCHER(IsEmpty, "") {
+MATCHER(IsEmptyJSON, "") {
    return 
       arg.road.empty() &&
       arg.city.empty() &&
@@ -23,7 +23,7 @@ MATCHER(IsEmpty, "") {
 TEST_F(AnAddressExtractor, ReturnsAnEmptyAddressOnAFailedParse) {
    auto address = extractor.addressFrom("not valid json");
 
-   ASSERT_THAT(address, IsEmpty());
+   ASSERT_THAT(address, IsEmptyJSON());
 }
 
 TEST_F(AnAddressExtractor, ReturnsAnEmptyAddressWhenNoAddressFound) {
@@ -31,7 +31,7 @@ TEST_F(AnAddressExtractor, ReturnsAnEmptyAddressWhenNoAddressFound) {
 
    auto address = extractor.addressFrom(json);
 
-   ASSERT_THAT(address, IsEmpty());
+   ASSERT_THAT(address, IsEmptyJSON());
 }

  1. Changed linked library to jsoncpp from json_linux-gcc

CMakeLists.txt

-target_link_libraries(test json_linux-gcc)
+target_link_libraries(test jsoncpp)
  1. Removed s from libs for JSONCPP_HOME
-$ENV{JSONCPP_HOME}/libs
+$ENV{JSONCPP_HOME}/lib
You must be logged in to comment