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

summaryrefslogtreecommitdiffhomepage
path: root/projects/SelfTest/ToStringGeneralTests.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2017-02-07 13:32:48 +0100
committerMartin Hořeňovský2017-02-07 13:32:48 +0100
commit7db4d8d90c84fd62f2b3dcefab66fe5f355f3918 (patch)
tree83f78170a5754f067c286533810fdef65b92db39 /projects/SelfTest/ToStringGeneralTests.cpp
parenta5ce57b34627d73da59562c1bca07d0378d6d2ec (diff)
downloadcatch3-7db4d8d90c84fd62f2b3dcefab66fe5f355f3918.tar.gz
Added tests (single char pretty printing + op overload)
Tests for issue #809 -- Potentional operator overload ambiguity -- and PR #646 -- Pretty print characters.
Diffstat (limited to 'projects/SelfTest/ToStringGeneralTests.cpp')
-rw-r--r--projects/SelfTest/ToStringGeneralTests.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/projects/SelfTest/ToStringGeneralTests.cpp b/projects/SelfTest/ToStringGeneralTests.cpp
new file mode 100644
index 00000000..a9fa4b83
--- /dev/null
+++ b/projects/SelfTest/ToStringGeneralTests.cpp
@@ -0,0 +1,40 @@
+/*
+ * Created by Martin on 17/02/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)
+ */
+
+#include "catch.hpp"
+
+
+TEST_CASE( "Character pretty printing" ){
+ //
+ SECTION("Specifically escaped"){
+ char tab = '\t';
+ char newline = '\n';
+ char carr_return = '\r';
+ char form_feed = '\f';
+ CHECK(tab == '\t');
+ CHECK(newline == '\n');
+ CHECK(carr_return == '\r');
+ CHECK(form_feed == '\f');
+ }
+ SECTION("General chars"){
+ char space = ' ';
+ CHECK(space == ' ');
+ char chars[] = {'a', 'z', 'A', 'Z'};
+ for (int i = 0; i < 4; ++i){
+ char c = chars[i];
+ REQUIRE(c == chars[i]);
+ }
+ }
+ SECTION("Low ASCII"){
+ char null_terminator = '\0';
+ CHECK(null_terminator == '\0');
+ for (int i = 2; i < 6; ++i){
+ char c = static_cast<char>(i);
+ REQUIRE(c == i);
+ }
+ }
+}