mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Split SelfTest test files into Usage and Introspective varieties
Usage: just exercises Catch. The tests are over arbitrary date/ types Introspective: Tests parts of Catch itself.
This commit is contained in:
parent
55b71bebf1
commit
e34754e433
@ -47,31 +47,32 @@ endfunction()
|
||||
# define the sources of the self test
|
||||
# Please keep these ordered alphabetically
|
||||
set(TEST_SOURCES
|
||||
${SELF_TEST_DIR}/ApproxTests.cpp
|
||||
${SELF_TEST_DIR}/BDDTests.cpp
|
||||
${SELF_TEST_DIR}/Benchmark.tests.cpp
|
||||
${SELF_TEST_DIR}/ClassTests.cpp
|
||||
${SELF_TEST_DIR}/CmdLineTests.cpp
|
||||
${SELF_TEST_DIR}/CompilationTests.cpp
|
||||
${SELF_TEST_DIR}/ConditionTests.cpp
|
||||
${SELF_TEST_DIR}/DecompositionTests.cpp
|
||||
${SELF_TEST_DIR}/EnumToString.cpp
|
||||
${SELF_TEST_DIR}/ExceptionTests.cpp
|
||||
${SELF_TEST_DIR}/MessageTests.cpp
|
||||
${SELF_TEST_DIR}/MiscTests.cpp
|
||||
${SELF_TEST_DIR}/PartTrackerTests.cpp
|
||||
${SELF_TEST_DIR}/TagAliasTests.cpp
|
||||
${SELF_TEST_DIR}/TestMain.cpp
|
||||
${SELF_TEST_DIR}/ToStringChrono.cpp
|
||||
${SELF_TEST_DIR}/ToStringGeneralTests.cpp
|
||||
${SELF_TEST_DIR}/ToStringPair.cpp
|
||||
${SELF_TEST_DIR}/ToStringTuple.cpp
|
||||
${SELF_TEST_DIR}/ToStringVector.cpp
|
||||
${SELF_TEST_DIR}/ToStringWhich.cpp
|
||||
${SELF_TEST_DIR}/TrickyTests.cpp
|
||||
${SELF_TEST_DIR}/VariadicMacrosTests.cpp
|
||||
${SELF_TEST_DIR}/MatchersTests.cpp
|
||||
${SELF_TEST_DIR}/StringRef.tests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/ApproxTests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/BDDTests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/Benchmark.tests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/ClassTests.cpp
|
||||
${SELF_TEST_DIR}/IntrospectiveTests/CmdLineTests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/CompilationTests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/ConditionTests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/DecompositionTests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/EnumToString.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/ExceptionTests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/MessageTests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/MiscTests.cpp
|
||||
${SELF_TEST_DIR}/IntrospectiveTests/PartTrackerTests.cpp
|
||||
${SELF_TEST_DIR}/IntrospectiveTests/TagAliasTests.cpp
|
||||
${SELF_TEST_DIR}/IntrospectiveTests/TestMain.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/ToStringChrono.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/ToStringGeneralTests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/ToStringPair.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/ToStringTuple.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/ToStringVector.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/ToStringWhich.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/TrickyTests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/VariadicMacrosTests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/MatchersTests.cpp
|
||||
${SELF_TEST_DIR}/IntrospectiveTests/StringRef.tests.cpp
|
||||
${SELF_TEST_DIR}/IntrospectiveTests/XmlTests.cpp
|
||||
)
|
||||
CheckFileList(TEST_SOURCES ${SELF_TEST_DIR})
|
||||
|
||||
|
@ -6670,10 +6670,10 @@ PASSED:
|
||||
XmlEncode
|
||||
normal string
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
XmlTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
XmlTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( encode( "normal string" ) == "normal string" )
|
||||
with expansion:
|
||||
@ -6683,10 +6683,10 @@ with expansion:
|
||||
XmlEncode
|
||||
empty string
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
XmlTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
XmlTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( encode( "" ) == "" )
|
||||
with expansion:
|
||||
@ -6696,10 +6696,10 @@ with expansion:
|
||||
XmlEncode
|
||||
string with ampersand
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
XmlTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
XmlTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( encode( "smith & jones" ) == "smith & jones" )
|
||||
with expansion:
|
||||
@ -6709,10 +6709,10 @@ with expansion:
|
||||
XmlEncode
|
||||
string with less-than
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
XmlTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
XmlTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( encode( "smith < jones" ) == "smith < jones" )
|
||||
with expansion:
|
||||
@ -6722,16 +6722,16 @@ with expansion:
|
||||
XmlEncode
|
||||
string with greater-than
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
XmlTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
XmlTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( encode( "smith > jones" ) == "smith > jones" )
|
||||
with expansion:
|
||||
"smith > jones" == "smith > jones"
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
XmlTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( encode( "smith ]]> jones" ) == "smith ]]> jones" )
|
||||
with expansion:
|
||||
@ -6743,10 +6743,10 @@ with expansion:
|
||||
XmlEncode
|
||||
string with quotes
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
XmlTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
XmlTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( encode( stringWithQuotes ) == stringWithQuotes )
|
||||
with expansion:
|
||||
@ -6754,7 +6754,7 @@ with expansion:
|
||||
==
|
||||
"don't "quote" me on that"
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
XmlTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) == "don't "quote" me on that" )
|
||||
with expansion:
|
||||
@ -6766,10 +6766,10 @@ with expansion:
|
||||
XmlEncode
|
||||
string with control char (1)
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
XmlTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
XmlTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( encode( "[\x01]" ) == "[\\x01]" )
|
||||
with expansion:
|
||||
@ -6779,10 +6779,10 @@ with expansion:
|
||||
XmlEncode
|
||||
string with control char (x7F)
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
XmlTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
XmlTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( encode( "[\x7F]" ) == "[\\x7F]" )
|
||||
with expansion:
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
#include "../include/internal/catch_stringref.h"
|
||||
#include "internal/catch_stringref.h"
|
||||
|
||||
#include "catch.hpp"
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch.hpp"
|
||||
#include "../include/reporters/catch_reporter_teamcity.hpp"
|
||||
#include "../include/reporters/catch_reporter_tap.hpp"
|
||||
#include "../include/reporters/catch_reporter_automake.hpp"
|
||||
#include "reporters/catch_reporter_teamcity.hpp"
|
||||
#include "reporters/catch_reporter_tap.hpp"
|
||||
#include "reporters/catch_reporter_automake.hpp"
|
||||
|
||||
|
||||
// Some example tag aliases
|
41
projects/SelfTest/IntrospectiveTests/XmlTests.cpp
Normal file
41
projects/SelfTest/IntrospectiveTests/XmlTests.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include "catch.hpp"
|
||||
|
||||
#include "internal/catch_xmlwriter.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
inline std::string encode( std::string const& str, Catch::XmlEncode::ForWhat forWhat = Catch::XmlEncode::ForTextNodes ) {
|
||||
std::ostringstream oss;
|
||||
oss << Catch::XmlEncode( str, forWhat );
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
TEST_CASE( "XmlEncode" ) {
|
||||
SECTION( "normal string" ) {
|
||||
REQUIRE( encode( "normal string" ) == "normal string" );
|
||||
}
|
||||
SECTION( "empty string" ) {
|
||||
REQUIRE( encode( "" ) == "" );
|
||||
}
|
||||
SECTION( "string with ampersand" ) {
|
||||
REQUIRE( encode( "smith & jones" ) == "smith & jones" );
|
||||
}
|
||||
SECTION( "string with less-than" ) {
|
||||
REQUIRE( encode( "smith < jones" ) == "smith < jones" );
|
||||
}
|
||||
SECTION( "string with greater-than" ) {
|
||||
REQUIRE( encode( "smith > jones" ) == "smith > jones" );
|
||||
REQUIRE( encode( "smith ]]> jones" ) == "smith ]]> jones" );
|
||||
}
|
||||
SECTION( "string with quotes" ) {
|
||||
std::string stringWithQuotes = "don't \"quote\" me on that";
|
||||
REQUIRE( encode( stringWithQuotes ) == stringWithQuotes );
|
||||
REQUIRE( encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) == "don't "quote" me on that" );
|
||||
}
|
||||
SECTION( "string with control char (1)" ) {
|
||||
REQUIRE( encode( "[\x01]" ) == "[\\x01]" );
|
||||
}
|
||||
SECTION( "string with control char (x7F)" ) {
|
||||
REQUIRE( encode( "[\x7F]" ) == "[\\x7F]" );
|
||||
}
|
||||
}
|
@ -13,7 +13,6 @@
|
||||
# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
||||
#endif
|
||||
|
||||
#include "internal/catch_xmlwriter.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cerrno>
|
||||
@ -293,42 +292,6 @@ TEST_CASE( "toString on wchar_t returns the string contents", "[toString]" ) {
|
||||
CHECK( result == "\"wide load\"" );
|
||||
}
|
||||
|
||||
inline std::string encode( std::string const& str, Catch::XmlEncode::ForWhat forWhat = Catch::XmlEncode::ForTextNodes ) {
|
||||
std::ostringstream oss;
|
||||
oss << Catch::XmlEncode( str, forWhat );
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
TEST_CASE( "XmlEncode" ) {
|
||||
SECTION( "normal string" ) {
|
||||
REQUIRE( encode( "normal string" ) == "normal string" );
|
||||
}
|
||||
SECTION( "empty string" ) {
|
||||
REQUIRE( encode( "" ) == "" );
|
||||
}
|
||||
SECTION( "string with ampersand" ) {
|
||||
REQUIRE( encode( "smith & jones" ) == "smith & jones" );
|
||||
}
|
||||
SECTION( "string with less-than" ) {
|
||||
REQUIRE( encode( "smith < jones" ) == "smith < jones" );
|
||||
}
|
||||
SECTION( "string with greater-than" ) {
|
||||
REQUIRE( encode( "smith > jones" ) == "smith > jones" );
|
||||
REQUIRE( encode( "smith ]]> jones" ) == "smith ]]> jones" );
|
||||
}
|
||||
SECTION( "string with quotes" ) {
|
||||
std::string stringWithQuotes = "don't \"quote\" me on that";
|
||||
REQUIRE( encode( stringWithQuotes ) == stringWithQuotes );
|
||||
REQUIRE( encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) == "don't "quote" me on that" );
|
||||
}
|
||||
SECTION( "string with control char (1)" ) {
|
||||
REQUIRE( encode( "[\x01]" ) == "[\\x01]" );
|
||||
}
|
||||
SECTION( "string with control char (x7F)" ) {
|
||||
REQUIRE( encode( "[\x7F]" ) == "[\\x7F]" );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "long long" ) {
|
||||
long long l = std::numeric_limits<long long>::max();
|
||||
|
Loading…
Reference in New Issue
Block a user