Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/projects/SelfTest/TestMain.cpp
diff options
context:
space:
mode:
authorPhil Nash2013-03-25 09:20:51 +0000
committerPhil Nash2013-03-25 09:20:51 +0000
commit2927c240a13326a978667f9ff5c87ec461089bdc (patch)
treed3266d4ca695f3308a21d78cfdd21808f4b051ec /projects/SelfTest/TestMain.cpp
parent29426b6359af60d6a49d7d444fbfabdf401ffe14 (diff)
downloadcatch3-2927c240a13326a978667f9ff5c87ec461089bdc.tar.gz
Fixed line wrap bug
Added line wrap tests and modified wrap algo to wrap within words using a -
Diffstat (limited to 'projects/SelfTest/TestMain.cpp')
-rw-r--r--projects/SelfTest/TestMain.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp
index e6c3830b..45e002a8 100644
--- a/projects/SelfTest/TestMain.cpp
+++ b/projects/SelfTest/TestMain.cpp
@@ -10,6 +10,7 @@
#endif
#include "catch_self_test.hpp"
+#include "catch_line_wrap.h"
TEST_CASE( "selftest/main", "Runs all Catch self tests and checks their results" ) {
using namespace Catch;
@@ -422,5 +423,37 @@ TEST_CASE( "selftest/tags", "" ) {
CHECK( oneTag.matchesTags( "~[hide]" ) == false );
}
+}
+
+TEST_CASE( "Long strings can be wrapped", "[wrap]" ) {
+ // guide: 123456789012345678
+ std::string testString = "one two three four";
+ SECTION( "No wrapping", "" ) {
+ CHECK( Catch::wrapLongStrings( testString, 80, 0 ) == testString );
+ CHECK( Catch::wrapLongStrings( testString, 18, 0 ) == testString );
+ }
+ SECTION( "Wrapped once", "" ) {
+ CHECK( Catch::wrapLongStrings( testString, 17, 0 ) == "one two three\nfour" );
+ CHECK( Catch::wrapLongStrings( testString, 16, 0 ) == "one two three\nfour" );
+ CHECK( Catch::wrapLongStrings( testString, 15, 0 ) == "one two three\nfour" );
+ CHECK( Catch::wrapLongStrings( testString, 14, 0 ) == "one two three\nfour" );
+ CHECK( Catch::wrapLongStrings( testString, 13, 0 ) == "one two\nthree four" );
+ }
+ SECTION( "Wrapped twice", "" ) {
+ CHECK( Catch::wrapLongStrings( testString, 9, 0 ) == "one two\nthree\nfour" );
+ CHECK( Catch::wrapLongStrings( testString, 8, 0 ) == "one two\nthree\nfour" );
+ }
+ SECTION( "Wrapped three times", "" ) {
+ CHECK( Catch::wrapLongStrings( testString, 7, 0 ) == "one\ntwo\nthree\nfour" );
+ CHECK( Catch::wrapLongStrings( testString, 5, 0 ) == "one\ntwo\nthree\nfour" );
+ }
+ SECTION( "Short wrap", "" ) {
+ CHECK( Catch::wrapLongStrings( "abcdef", 4, 0 ) == "abc-\ndef" );
+ CHECK( Catch::wrapLongStrings( "abcdefg", 4, 0 ) == "abc-\ndefg" );
+ CHECK( Catch::wrapLongStrings( "abcdefgh", 4, 0 ) == "abc-\ndef-\ngh" );
+
+ CHECK( Catch::wrapLongStrings( testString, 4, 0 ) == "one\ntwo\nthr-\nee\nfour" );
+ CHECK( Catch::wrapLongStrings( testString, 3, 0 ) == "one\ntwo\nth-\nree\nfo-\nur" );
+ }
}