Some minor tidy-up/ style alignment of recent toString merges
diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt
index d2e42b4..a97b7a3 100644
--- a/projects/SelfTest/Baselines/console.std.approved.txt
+++ b/projects/SelfTest/Baselines/console.std.approved.txt
@@ -787,5 +787,5 @@
===============================================================================
test cases: 148 | 109 passed | 38 failed | 1 failed as expected
-assertions: 738 | 646 passed | 79 failed | 13 failed as expected
+assertions: 739 | 647 passed | 79 failed | 13 failed as expected
diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt
index 169f263..54b7c91 100644
--- a/projects/SelfTest/Baselines/console.sw.approved.txt
+++ b/projects/SelfTest/Baselines/console.sw.approved.txt
@@ -75,6 +75,14 @@
with expansion:
"E2/V1" == "E2/V1"
+EnumToString.cpp:<line number>:
+PASSED:
+ CHECK( Catch::toString(e3) == "Unknown enum value 10" )
+with expansion:
+ "Unknown enum value 10"
+ ==
+ "Unknown enum value 10"
+
-------------------------------------------------------------------------------
Some simple comparisons between doubles
-------------------------------------------------------------------------------
@@ -7676,5 +7684,5 @@
===============================================================================
test cases: 148 | 93 passed | 54 failed | 1 failed as expected
-assertions: 758 | 646 passed | 99 failed | 13 failed as expected
+assertions: 759 | 647 passed | 99 failed | 13 failed as expected
diff --git a/projects/SelfTest/Baselines/console.swa4.approved.txt b/projects/SelfTest/Baselines/console.swa4.approved.txt
index 276c93e..c899301 100644
--- a/projects/SelfTest/Baselines/console.swa4.approved.txt
+++ b/projects/SelfTest/Baselines/console.swa4.approved.txt
@@ -75,6 +75,14 @@
with expansion:
"E2/V1" == "E2/V1"
+EnumToString.cpp:<line number>:
+PASSED:
+ CHECK( Catch::toString(e3) == "Unknown enum value 10" )
+with expansion:
+ "Unknown enum value 10"
+ ==
+ "Unknown enum value 10"
+
-------------------------------------------------------------------------------
Some simple comparisons between doubles
-------------------------------------------------------------------------------
@@ -479,5 +487,5 @@
===============================================================================
test cases: 19 | 15 passed | 3 failed | 1 failed as expected
-assertions: 61 | 55 passed | 4 failed | 2 failed as expected
+assertions: 62 | 56 passed | 4 failed | 2 failed as expected
diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt
index 7ce10d7..07984f5 100644
--- a/projects/SelfTest/Baselines/junit.sw.approved.txt
+++ b/projects/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,5 +1,5 @@
<testsuites>
- <testsuite errors="12" failures="87" tests="758" hostname="tbd" time="{duration}" timestamp="tbd">
+ <testsuite errors="12" failures="87" tests="759" hostname="tbd" time="{duration}" timestamp="tbd">
<testcase classname="global" name="toString(enum)" time="{duration}"/>
<testcase classname="global" name="toString(enum w/operator<<)" time="{duration}"/>
<testcase classname="global" name="toString(enum class)" time="{duration}"/>
diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt
index 5c06f6e..146a9eb 100644
--- a/projects/SelfTest/Baselines/xml.sw.approved.txt
+++ b/projects/SelfTest/Baselines/xml.sw.approved.txt
@@ -74,6 +74,16 @@
"E2/V1" == "E2/V1"
</Expanded>
</Expression>
+ <Expression success="true" filename="/Users/philnash/Dev/OSS/Catch-Dev/projects/SelfTest/EnumToString.cpp" >
+ <Original>
+ Catch::toString(e3) == "Unknown enum value 10"
+ </Original>
+ <Expanded>
+ "Unknown enum value 10"
+==
+"Unknown enum value 10"
+ </Expanded>
+ </Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="Some simple comparisons between doubles">
@@ -7940,7 +7950,7 @@
</Section>
<OverallResult success="true"/>
</TestCase>
- <OverallResults successes="646" failures="99" expectedFailures="13"/>
+ <OverallResults successes="647" failures="99" expectedFailures="13"/>
</Group>
- <OverallResults successes="646" failures="99" expectedFailures="13"/>
+ <OverallResults successes="647" failures="99" expectedFailures="13"/>
</Catch>
diff --git a/projects/SelfTest/EnumToString.cpp b/projects/SelfTest/EnumToString.cpp
index 40c11ca..b35721d 100644
--- a/projects/SelfTest/EnumToString.cpp
+++ b/projects/SelfTest/EnumToString.cpp
@@ -8,8 +8,7 @@
// Enum without user-provided stream operator
enum Enum1 { Enum1Value0, Enum1Value1 };
-TEST_CASE( "toString(enum)", "[toString][enum]" )
-{
+TEST_CASE( "toString(enum)", "[toString][enum]" ) {
Enum1 e0 = Enum1Value0;
CHECK( Catch::toString(e0) == "0" );
Enum1 e1 = Enum1Value1;
@@ -19,13 +18,11 @@
// Enum with user-provided stream operator
enum Enum2 { Enum2Value0, Enum2Value1 };
-inline std::ostream& operator<<( std::ostream& os, Enum2 v )
-{
+inline std::ostream& operator<<( std::ostream& os, Enum2 v ) {
return os << "E2{" << static_cast<int>(v) << "}";
}
-TEST_CASE( "toString(enum w/operator<<)", "[toString][enum]" )
-{
+TEST_CASE( "toString(enum w/operator<<)", "[toString][enum]" ) {
Enum2 e0 = Enum2Value0;
CHECK( Catch::toString(e0) == "E2{0}" );
Enum2 e1 = Enum2Value1;
@@ -33,11 +30,15 @@
}
#if defined(CATCH_CPP11_OR_GREATER)
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++98-compat"
+#endif
+
// Enum class without user-provided stream operator
enum class EnumClass1 { EnumClass1Value0, EnumClass1Value1 };
-TEST_CASE( "toString(enum class)", "[toString][enum][enumClass]" )
-{
+TEST_CASE( "toString(enum class)", "[toString][enum][enumClass]" ) {
EnumClass1 e0 = EnumClass1::EnumClass1Value0;
CHECK( Catch::toString(e0) == "0" );
EnumClass1 e1 = EnumClass1::EnumClass1Value1;
@@ -47,25 +48,29 @@
// Enum class with user-provided stream operator
enum class EnumClass2 : short { EnumClass2Value0, EnumClass2Value1 };
-inline std::ostream& operator<<( std::ostream& os, EnumClass2 e2 )
-{
- switch( e2 )
- {
- case EnumClass2::EnumClass2Value0:
- return os << "E2/V0";
- case EnumClass2::EnumClass2Value1:
- return os << "E2/V1";
+inline std::ostream& operator<<( std::ostream& os, EnumClass2 e2 ) {
+ switch( (int)e2 ) {
+ case (int)EnumClass2::EnumClass2Value0:
+ return os << "E2/V0";
+ case (int)EnumClass2::EnumClass2Value1:
+ return os << "E2/V1";
+ default:
+ return os << "Unknown enum value " << (int)e2;
}
- return os << "unexpected...";
}
-TEST_CASE( "toString(enum class w/operator<<)", "[toString][enum][enumClass]" )
-{
+TEST_CASE( "toString(enum class w/operator<<)", "[toString][enum][enumClass]" ) {
EnumClass2 e0 = EnumClass2::EnumClass2Value0;
CHECK( Catch::toString(e0) == "E2/V0" );
EnumClass2 e1 = EnumClass2::EnumClass2Value1;
CHECK( Catch::toString(e1) == "E2/V1" );
+
+ EnumClass2 e3 = static_cast<EnumClass2>(10);
+ CHECK( Catch::toString(e3) == "Unknown enum value 10" );
}
+#ifdef __clang__
+#pragma clang diagnostic pop
#endif
+#endif // CATCH_CPP11_OR_GREATER
diff --git a/projects/SelfTest/ToStringPair.cpp b/projects/SelfTest/ToStringPair.cpp
index 2de4a55..8f51070 100644
--- a/projects/SelfTest/ToStringPair.cpp
+++ b/projects/SelfTest/ToStringPair.cpp
@@ -18,28 +18,24 @@
};
}
-TEST_CASE( "std::pair<int,std::string> -> toString", "[toString][pair]" )
-{
+TEST_CASE( "std::pair<int,std::string> -> toString", "[toString][pair]" ) {
std::pair<int,std::string> value( 34, "xyzzy" );
REQUIRE( Catch::toString( value ) == "{ 34, \"xyzzy\" }" );
}
-TEST_CASE( "std::pair<int,const std::string> -> toString", "[toString][pair]" )
-{
+TEST_CASE( "std::pair<int,const std::string> -> toString", "[toString][pair]" ) {
std::pair<int,const std::string> value( 34, "xyzzy" );
REQUIRE( Catch::toString(value) == "{ 34, \"xyzzy\" }" );
}
-TEST_CASE( "std::vector<std::pair<std::string,int> > -> toString", "[toString][pair]" )
-{
+TEST_CASE( "std::vector<std::pair<std::string,int> > -> toString", "[toString][pair]" ) {
std::vector<std::pair<std::string,int> > pr;
pr.push_back( std::make_pair("green", 55 ) );
REQUIRE( Catch::toString( pr ) == "{ { \"green\", 55 } }" );
}
// This is pretty contrived - I figure if this works, anything will...
-TEST_CASE( "pair<pair<int,const char *,pair<std::string,int> > -> toString", "[toString][pair]" )
-{
+TEST_CASE( "pair<pair<int,const char *,pair<std::string,int> > -> toString", "[toString][pair]" ) {
typedef std::pair<int,const char *> left_t;
typedef std::pair<std::string,int> right_t;
diff --git a/projects/SelfTest/ToStringVector.cpp b/projects/SelfTest/ToStringVector.cpp
index f3b036e..4479060 100644
--- a/projects/SelfTest/ToStringVector.cpp
+++ b/projects/SelfTest/ToStringVector.cpp
@@ -24,6 +24,11 @@
}
#if defined(CATCH_CPP11_OR_GREATER)
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++98-compat"
+#endif
+
/*
Note: These tests *can* be made to work with C++ < 11, but the
allocator is a lot more work...
@@ -34,12 +39,10 @@
struct minimal_allocator {
typedef T value_type;
typedef std::size_t size_type;
- T *allocate( size_type n )
- {
+ T *allocate( size_type n ) {
return static_cast<T *>( ::operator new( n * sizeof(T) ) );
}
- void deallocate( T *p, size_type /*n*/ )
- {
+ void deallocate( T *p, size_type /*n*/ ) {
::operator delete( static_cast<void *>(p) );
}
template<typename U>
@@ -49,8 +52,7 @@
};
}
-TEST_CASE( "vector<int,allocator> -> toString", "[toString][vector,allocator]" )
-{
+TEST_CASE( "vector<int,allocator> -> toString", "[toString][vector,allocator]" ) {
std::vector<int,minimal_allocator<int> > vv;
REQUIRE( Catch::toString(vv) == "{ }" );
vv.push_back( 42 );
@@ -59,8 +61,7 @@
REQUIRE( Catch::toString(vv) == "{ 42, 512 }" );
}
-TEST_CASE( "vec<vec<string,alloc>> -> toString", "[toString][vector,allocator]" )
-{
+TEST_CASE( "vec<vec<string,alloc>> -> toString", "[toString][vector,allocator]" ) {
typedef std::vector<std::string,minimal_allocator<std::string> > inner;
typedef std::vector<inner> vector;
vector v;
@@ -69,4 +70,8 @@
v.push_back( inner { "world" } );
REQUIRE( Catch::toString(v) == "{ { \"hello\" }, { \"world\" } }" );
}
+
+#ifdef __clang__
+#pragma clang diagnostic pop
#endif
+#endif // CATCH_CPP11_OR_GREATER
diff --git a/projects/SelfTest/ToStringWhich.cpp b/projects/SelfTest/ToStringWhich.cpp
index 785c65b..1d4aa89 100644
--- a/projects/SelfTest/ToStringWhich.cpp
+++ b/projects/SelfTest/ToStringWhich.cpp
@@ -31,43 +31,37 @@
}
// Call the overload
-TEST_CASE( "toString( has_toString )", "[toString]" )
-{
+TEST_CASE( "toString( has_toString )", "[toString]" ) {
has_toString item;
REQUIRE( Catch::toString( item ) == "toString( has_toString )" );
}
// Call the overload
-TEST_CASE( "toString( has_maker )", "[toString]" )
-{
+TEST_CASE( "toString( has_maker )", "[toString]" ) {
has_maker item;
REQUIRE( Catch::toString( item ) == "StringMaker<has_maker>" );
}
// Call the overload
-TEST_CASE( "toString( has_maker_and_toString )", "[toString]" )
-{
+TEST_CASE( "toString( has_maker_and_toString )", "[toString]" ) {
has_maker_and_toString item;
REQUIRE( Catch::toString( item ) == "toString( has_maker_and_toString )" );
}
// Vectors...
-TEST_CASE( "toString( vectors<has_toString )", "[toString]" )
-{
+TEST_CASE( "toString( vectors<has_toString )", "[toString]" ) {
std::vector<has_toString> v(1);
// This invokes template<T> toString which actually gives us '{ ? }'
REQUIRE( Catch::toString( v ) == "{ {?} }" );
}
-TEST_CASE( "toString( vectors<has_maker )", "[toString]" )
-{
+TEST_CASE( "toString( vectors<has_maker )", "[toString]" ) {
std::vector<has_maker> v(1);
REQUIRE( Catch::toString( v ) == "{ StringMaker<has_maker> }" );
}
-TEST_CASE( "toString( vectors<has_maker_and_toString )", "[toString]" )
-{
+TEST_CASE( "toString( vectors<has_maker_and_toString )", "[toString]" ) {
std::vector<has_maker_and_toString> v(1);
// Note: This invokes the template<T> toString -> StringMaker
REQUIRE( Catch::toString( v ) == "{ StringMaker<has_maker_and_toString> }" );