-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'topic/12540-printing-types-customisation-point' into ne…
…xt-internal * topic/12540-printing-types-customisation-point: Change log update Documenting the customization point Fixing the tests and checking everything works ok Test for customization points Customization points for printing user defined types through `boost_test_print_type`
- Loading branch information
Showing
8 changed files
with
176 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//[example_output | ||
> logger-customization-point --log_level=all | ||
Running 1 test case... | ||
Entering test module "logger-customization-point" | ||
test.cpp(36): Entering test case "test1" | ||
test.cpp(39): error: in "test1": check t == 11 has failed [** value of user_defined_type is 10 ** != 11] | ||
test.cpp(43): info: check t2 == 11 has passed | ||
test.cpp(36): Leaving test case "test1"; testing time: 125us | ||
Leaving test module "logger-example-customization-point"; testing time: 157us | ||
|
||
*** 1 failure is detected in the test module "logger-customization-point" | ||
//] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// (C) Copyright Raffi Enficiaud 2017. | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
// See http://www.boost.org/libs/test for the library home page. | ||
// | ||
//! @file | ||
//! Customization point for printing user defined types | ||
// ***************************************************************************** | ||
|
||
//[example_code | ||
#define BOOST_TEST_MODULE logger-customization-point | ||
#include <boost/test/included/unit_test.hpp> | ||
|
||
namespace user_defined_namespace { | ||
struct user_defined_type { | ||
int value; | ||
|
||
user_defined_type(int value_) : value(value_) | ||
{} | ||
|
||
bool operator==(int right) const { | ||
return right == value; | ||
} | ||
}; | ||
} | ||
|
||
namespace user_defined_namespace { | ||
std::ostream& boost_test_print_type(std::ostream& ostr, user_defined_type const& right) { | ||
ostr << "** value of user_defined_type is " << right.value << " **"; | ||
return ostr; | ||
} | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(test1) | ||
{ | ||
user_defined_namespace::user_defined_type t(10); | ||
BOOST_TEST(t == 11); | ||
|
||
using namespace user_defined_namespace; | ||
user_defined_type t2(11); | ||
BOOST_TEST(t2 == 11); | ||
} | ||
//] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
test/writing-test-ts/user-defined-types-logging-customization-points.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// (C) Copyright Raffi Enficiaud 2017. | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
// See http://www.boost.org/libs/test for the library home page. | ||
// | ||
//! @file | ||
//! Customization point for printing user defined types | ||
// ***************************************************************************** | ||
|
||
#define BOOST_TEST_MODULE user type logger customization points | ||
#include <boost/test/unit_test.hpp> | ||
|
||
namespace printing_test { | ||
struct user_defined_type { | ||
int value; | ||
|
||
user_defined_type(int value_) : value(value_) | ||
{} | ||
|
||
bool operator==(int right) const { | ||
return right == value; | ||
} | ||
}; | ||
|
||
std::ostream& boost_test_print_type(std::ostream& ostr, user_defined_type const& right) { | ||
ostr << "** value of my type is " << right.value << " **"; | ||
return ostr; | ||
} | ||
} | ||
|
||
//using namespace printing_test; | ||
|
||
BOOST_AUTO_TEST_CASE(test1) | ||
{ | ||
//using printing_test::user_defined_type; | ||
printing_test::user_defined_type t(10); | ||
BOOST_CHECK_EQUAL(t, 10); | ||
#ifndef BOOST_TEST_MACRO_LIMITED_SUPPORT | ||
BOOST_TEST(t == 10); | ||
#endif | ||
} |