aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/catchy
diff options
context:
space:
mode:
authorSimon Warta <[email protected]>2015-07-18 16:37:48 +0200
committerSimon Warta <[email protected]>2015-08-08 00:47:58 +0200
commit463f55bf59c77adb4101cbeeccf20b3f15975185 (patch)
treecc77035eec9ebee41f7764298afe2368dcd6f0f3 /src/tests/catchy
parent63c1958b841d26184c526b54c531b0188c34ab0a (diff)
Refactor catchy tests
* Add std::vector matcher * Add test_base to ensure Botan::vector<X> works with matcher * Rewrite base64 tests from CHECK( to CHECK_THAT( Closes #206
Diffstat (limited to 'src/tests/catchy')
-rw-r--r--src/tests/catchy/catchy_tests.h52
-rw-r--r--src/tests/catchy/test_base.cpp25
-rw-r--r--src/tests/catchy/test_base64.cpp188
-rw-r--r--src/tests/catchy/test_cvc.cpp3
-rw-r--r--src/tests/catchy/test_stl_util.cpp12
-rw-r--r--src/tests/catchy/test_utils.cpp2
-rw-r--r--src/tests/catchy/test_x509.cpp3
7 files changed, 179 insertions, 106 deletions
diff --git a/src/tests/catchy/catchy_tests.h b/src/tests/catchy/catchy_tests.h
new file mode 100644
index 000000000..d94cd6c92
--- /dev/null
+++ b/src/tests/catchy/catchy_tests.h
@@ -0,0 +1,52 @@
+// (C) 2015 Simon Warta (Kullo GmbH)
+// Botan is released under the Simplified BSD License (see license.txt)
+
+#ifndef BOTAN_CATCHY_TESTS_H__
+#define BOTAN_CATCHY_TESTS_H__
+
+#include "catch.hpp"
+#include <botan/build.h>
+
+
+// BEGIN CATCH STD::VECTOR IMPLEMENTATION
+// This is basically https://github.com/philsquared/Catch/pull/466
+#include <vector>
+
+namespace Catch {
+
+namespace Matchers {
+ namespace Impl {
+
+ namespace StdVector {
+ template<typename T, typename Alloc>
+ struct Equals : MatcherImpl<Equals<T, Alloc>, std::vector<T, Alloc> > {
+ Equals( std::vector<T, Alloc> const& vec ) : m_vector( vec ){}
+ Equals( Equals const& other ) : m_vector( other.m_vector ){}
+
+ virtual ~Equals() {};
+
+ virtual bool match( std::vector<T, Alloc> const& expr ) const {
+ return m_vector == expr;
+ }
+ virtual std::string toString() const {
+ return "equals: std::vector of length " + Catch::toString(m_vector.size());
+ }
+
+ std::vector<T, Alloc> m_vector;
+ };
+ } // namespace StdVector
+
+ } // namespace Impl
+
+ // The following functions create the actual matcher objects.
+ // This allows the types to be inferred
+ template <typename T, typename Alloc>
+ inline Impl::StdVector::Equals<T, Alloc> Equals( std::vector<T, Alloc> const& vec ) {
+ return Impl::StdVector::Equals<T, Alloc>( vec );
+ }
+
+} // namespace Matchers
+} // namespace Catch
+// END CATCH STD::VECTOR IMPLEMENTATION
+
+#endif // BOTAN_CATCHY_TESTS_H__
diff --git a/src/tests/catchy/test_base.cpp b/src/tests/catchy/test_base.cpp
new file mode 100644
index 000000000..057b29eb3
--- /dev/null
+++ b/src/tests/catchy/test_base.cpp
@@ -0,0 +1,25 @@
+// (C) 2015 Simon Warta (Kullo GmbH)
+// Botan is released under the Simplified BSD License (see license.txt)
+
+#include "catchy_tests.h"
+#include <botan/symkey.h>
+
+using namespace Botan;
+
+TEST_CASE("OctetString", "[base]")
+ {
+ auto empty = secure_vector<byte>{ };
+ auto one = secure_vector<byte>{ 94 }; // ^
+ auto some = secure_vector<byte>{ 0x48, 0x65, 0x6c, 0x6c, 0x6f }; // Hello
+ auto utf8 = secure_vector<byte>{ 0xc3, 0xb6 }; // ö
+
+ auto os_empty = OctetString("");
+ auto os_one = OctetString("5e");
+ auto os_some = OctetString("48656c6c6f");
+ auto os_utf8 = OctetString("c3b6");
+
+ CHECK_THAT(os_empty.bits_of(), Equals(empty));
+ CHECK_THAT(os_one.bits_of(), Equals(one));
+ CHECK_THAT(os_some.bits_of(), Equals(some));
+ CHECK_THAT(os_utf8.bits_of(), Equals(utf8));
+ }
diff --git a/src/tests/catchy/test_base64.cpp b/src/tests/catchy/test_base64.cpp
index e25defb09..fe7739a8d 100644
--- a/src/tests/catchy/test_base64.cpp
+++ b/src/tests/catchy/test_base64.cpp
@@ -1,9 +1,7 @@
// (C) 2015 Simon Warta (Kullo GmbH)
// Botan is released under the Simplified BSD License (see license.txt)
-#include "catch.hpp"
-
-#include <botan/build.h>
+#include "catchy_tests.h"
#if defined(BOTAN_HAS_BASE64_CODEC)
@@ -26,7 +24,7 @@ TEST_CASE("Base64 encode empty string", "[base64]")
// common knowledge
auto emptyString = std::string("");
auto emptyVector = std::vector<Botan::byte>(emptyString.cbegin(), emptyString.cend());
- CHECK(( Botan::base64_encode(emptyVector) == "" ));
+ CHECK_THAT(Botan::base64_encode(emptyVector), Equals(""));
}
TEST_CASE("Base64 encode short string", "[base64]")
@@ -35,9 +33,9 @@ TEST_CASE("Base64 encode short string", "[base64]")
auto in1 = std::vector<Botan::byte>{ 'f' };
auto in2 = std::vector<Botan::byte>{ 'f', 'o' };
auto in3 = std::vector<Botan::byte>{ 'f', 'o', 'o' };
- CHECK(( Botan::base64_encode(in1) == "Zg==" ));
- CHECK(( Botan::base64_encode(in2) == "Zm8=" ));
- CHECK(( Botan::base64_encode(in3) == "Zm9v" ));
+ CHECK_THAT(Botan::base64_encode(in1), Equals("Zg=="));
+ CHECK_THAT(Botan::base64_encode(in2), Equals("Zm8="));
+ CHECK_THAT(Botan::base64_encode(in3), Equals("Zm9v"));
}
TEST_CASE("Base64 encode string", "[base64]")
@@ -50,13 +48,13 @@ TEST_CASE("Base64 encode string", "[base64]")
auto in5 = std::vector<Botan::byte>{ 'T','h','e',' ','1','3',' ','c','h','a','r','s','.' };
auto in6 = std::vector<Botan::byte>{ 'T','h','e',' ','1','4',' ','c','h','a','r','s','.','.' };
auto in7 = std::vector<Botan::byte>{ 'T','h','e',' ','1','5',' ','c','h','a','r','s','.','.','.' };
- CHECK(( Botan::base64_encode(in1) == "aGVsbG8gd29ybGQ=" ));
- CHECK(( Botan::base64_encode(in2) == "aGVsbG8gd29ybGQh" ));
- CHECK(( Botan::base64_encode(in3) == "SGVsbG8sIHdvcmxkLg==" ));
- CHECK(( Botan::base64_encode(in4) == "VGhlIDEyIGNoYXJz" ));
- CHECK(( Botan::base64_encode(in5) == "VGhlIDEzIGNoYXJzLg==" ));
- CHECK(( Botan::base64_encode(in6) == "VGhlIDE0IGNoYXJzLi4=" ));
- CHECK(( Botan::base64_encode(in7) == "VGhlIDE1IGNoYXJzLi4u" ));
+ CHECK_THAT(Botan::base64_encode(in1), Equals("aGVsbG8gd29ybGQ="));
+ CHECK_THAT(Botan::base64_encode(in2), Equals("aGVsbG8gd29ybGQh"));
+ CHECK_THAT(Botan::base64_encode(in3), Equals("SGVsbG8sIHdvcmxkLg=="));
+ CHECK_THAT(Botan::base64_encode(in4), Equals("VGhlIDEyIGNoYXJz"));
+ CHECK_THAT(Botan::base64_encode(in5), Equals("VGhlIDEzIGNoYXJzLg=="));
+ CHECK_THAT(Botan::base64_encode(in6), Equals("VGhlIDE0IGNoYXJzLi4="));
+ CHECK_THAT(Botan::base64_encode(in7), Equals("VGhlIDE1IGNoYXJzLi4u"));
}
TEST_CASE("Base64 encode string special chars", "[base64]")
@@ -64,72 +62,72 @@ TEST_CASE("Base64 encode string special chars", "[base64]")
// Generated by: echo -n "xyz" | base64
auto in1 = toStdVector("An UTF-8 uuml: ü");
auto in2 = toStdVector("Weird German 2 byte thing: ß.");
- CHECK(( Botan::base64_encode(in1) == "QW4gVVRGLTggdXVtbDogw7w=" ));
- CHECK(( Botan::base64_encode(in2) == "V2VpcmQgR2VybWFuIDIgYnl0ZSB0aGluZzogw58u" ));
+ CHECK_THAT(Botan::base64_encode(in1), Equals("QW4gVVRGLTggdXVtbDogw7w="));
+ CHECK_THAT(Botan::base64_encode(in2), Equals("V2VpcmQgR2VybWFuIDIgYnl0ZSB0aGluZzogw58u"));
}
TEST_CASE("Base64 encode empty binary", "[base64]")
{
auto binary0 = std::vector<unsigned char>{};
- CHECK(( Botan::base64_encode(binary0) == "" ));
+ CHECK_THAT(Botan::base64_encode(binary0), Equals(""));
}
TEST_CASE("Base64 encode binary", "[base64]")
{
// Generated by: cat /dev/urandom | head -c 3 | tee /tmp/mybinary | hexdump -C && cat /tmp/mybinary | base64
std::vector<unsigned char> binary1 = {0x9b};
- CHECK(( Botan::base64_encode(binary1) == "mw==" ));
+ CHECK_THAT(Botan::base64_encode(binary1), Equals("mw=="));
std::vector<unsigned char> binary2 = {0x1c, 0x60};
- CHECK(( Botan::base64_encode(binary2) == "HGA=" ));
+ CHECK_THAT(Botan::base64_encode(binary2), Equals("HGA="));
std::vector<unsigned char> binary3 = {0x81, 0x34, 0xbd};
- CHECK(( Botan::base64_encode(binary3) == "gTS9" ));
+ CHECK_THAT(Botan::base64_encode(binary3), Equals("gTS9"));
std::vector<unsigned char> binary4 = {0x5e, 0x6c, 0xff, 0xde};
- CHECK(( Botan::base64_encode(binary4) == "Xmz/3g==" ));
+ CHECK_THAT(Botan::base64_encode(binary4), Equals("Xmz/3g=="));
std::vector<unsigned char> binary5 = {0xb2, 0xcd, 0xf0, 0xdc, 0x7f};
- CHECK(( Botan::base64_encode(binary5) == "ss3w3H8=" ));
+ CHECK_THAT(Botan::base64_encode(binary5), Equals("ss3w3H8="));
std::vector<unsigned char> binary6 = {0xfc, 0x56, 0x2d, 0xda, 0xd4, 0x0e};
- CHECK(( Botan::base64_encode(binary6) == "/FYt2tQO" ));
+ CHECK_THAT(Botan::base64_encode(binary6), Equals("/FYt2tQO"));
std::vector<unsigned char> binary7 = {0x29, 0xb2, 0x32, 0x2e, 0x88, 0x41, 0xe8};
- CHECK(( Botan::base64_encode(binary7) == "KbIyLohB6A==" ));
+ CHECK_THAT(Botan::base64_encode(binary7), Equals("KbIyLohB6A=="));
std::vector<unsigned char> binary8 = {0x0f, 0x0f, 0xce, 0xd9, 0x49, 0x7a, 0xaf, 0x92};
- CHECK(( Botan::base64_encode(binary8) == "Dw/O2Ul6r5I=" ));
+ CHECK_THAT(Botan::base64_encode(binary8), Equals("Dw/O2Ul6r5I="));
std::vector<unsigned char> binary9 = {0x27, 0x0f, 0xb1, 0x89, 0x82, 0x80, 0x0d, 0xa6, 0x40};
- CHECK(( Botan::base64_encode(binary9) == "Jw+xiYKADaZA" ));
+ CHECK_THAT(Botan::base64_encode(binary9), Equals("Jw+xiYKADaZA"));
}
TEST_CASE("Base64 decode empty string", "[base64]")
{
// common knowledge
auto outVector = toStdVector(Botan::base64_decode(""));
- CHECK(( outVector == std::vector<Botan::byte>{} ));
+ CHECK_THAT(outVector, Equals(std::vector<Botan::byte>{}));
}
TEST_CASE("Base64 decode short string", "[base64]")
{
// test vectors from http://tools.ietf.org/html/rfc4648
- CHECK(( toStdVector(Botan::base64_decode("Zg==")) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode("Zm8=")) == toStdVector("fo") ));
- CHECK(( toStdVector(Botan::base64_decode("Zm9v")) == toStdVector("foo") ));
+ CHECK_THAT(toStdVector(Botan::base64_decode("Zg==")), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode("Zm8=")), Equals(toStdVector("fo")));
+ CHECK_THAT(toStdVector(Botan::base64_decode("Zm9v")), Equals(toStdVector("foo")));
}
TEST_CASE("Base64 decode string", "[base64]")
{
// Generated by: echo -n "xyz" | base64
- CHECK(( toStdVector(Botan::base64_decode("aGVsbG8gd29ybGQ=")) == toStdVector("hello world") ));
- CHECK(( toStdVector(Botan::base64_decode("aGVsbG8gd29ybGQh")) == toStdVector("hello world!") ));
- CHECK(( toStdVector(Botan::base64_decode("SGVsbG8sIHdvcmxkLg==")) == toStdVector("Hello, world.") ));
- CHECK(( toStdVector(Botan::base64_decode("VGhlIDEyIGNoYXJz")) == toStdVector("The 12 chars") ));
- CHECK(( toStdVector(Botan::base64_decode("VGhlIDEzIGNoYXJzLg==")) == toStdVector("The 13 chars.") ));
- CHECK(( toStdVector(Botan::base64_decode("VGhlIDE0IGNoYXJzLi4=")) == toStdVector("The 14 chars..") ));
- CHECK(( toStdVector(Botan::base64_decode("VGhlIDE1IGNoYXJzLi4u")) == toStdVector("The 15 chars...") ));
+ CHECK_THAT(toStdVector(Botan::base64_decode("aGVsbG8gd29ybGQ=")), Equals(toStdVector("hello world")));
+ CHECK_THAT(toStdVector(Botan::base64_decode("aGVsbG8gd29ybGQh")), Equals(toStdVector("hello world!")));
+ CHECK_THAT(toStdVector(Botan::base64_decode("SGVsbG8sIHdvcmxkLg==")), Equals(toStdVector("Hello, world.")));
+ CHECK_THAT(toStdVector(Botan::base64_decode("VGhlIDEyIGNoYXJz")), Equals(toStdVector("The 12 chars")));
+ CHECK_THAT(toStdVector(Botan::base64_decode("VGhlIDEzIGNoYXJzLg==")), Equals(toStdVector("The 13 chars.")));
+ CHECK_THAT(toStdVector(Botan::base64_decode("VGhlIDE0IGNoYXJzLi4=")), Equals(toStdVector("The 14 chars..")));
+ CHECK_THAT(toStdVector(Botan::base64_decode("VGhlIDE1IGNoYXJzLi4u")), Equals(toStdVector("The 15 chars...")));
}
TEST_CASE("Base64 decode string special chars", "[base64]")
@@ -139,96 +137,96 @@ TEST_CASE("Base64 decode string special chars", "[base64]")
auto in2 = std::string("V2VpcmQgR2VybWFuIDIgYnl0ZSB0aGluZzogw58u");
auto out1 = std::string("An UTF-8 uuml: ü");
auto out2 = std::string("Weird German 2 byte thing: ß.");
- CHECK(( toStdVector(Botan::base64_decode(in1)) == toStdVector(out1) ));
- CHECK(( toStdVector(Botan::base64_decode(in2)) == toStdVector(out2) ));
+ CHECK_THAT(toStdVector(Botan::base64_decode(in1)), Equals(toStdVector(out1)));
+ CHECK_THAT(toStdVector(Botan::base64_decode(in2)), Equals(toStdVector(out2)));
}
TEST_CASE("Base64 decode binary", "[base64]")
{
// Generated by: cat /dev/urandom | head -c 3 | tee /tmp/mybinary | hexdump -C && cat /tmp/mybinary | base64
std::vector<unsigned char> binary0 = {};
- CHECK(( toStdVector(Botan::base64_decode("")) == binary0));
+ CHECK_THAT(toStdVector(Botan::base64_decode("")), Equals(binary0));
std::vector<unsigned char> binary1 = {0x9b};
- CHECK(( toStdVector(Botan::base64_decode("mw==")) == binary1 ));
+ CHECK_THAT(toStdVector(Botan::base64_decode("mw==")), Equals(binary1));
std::vector<unsigned char> binary2 = {0x1c, 0x60};
- CHECK(( toStdVector(Botan::base64_decode("HGA=")) == binary2 ));
+ CHECK_THAT(toStdVector(Botan::base64_decode("HGA=")), Equals(binary2));
std::vector<unsigned char> binary3 = {0x81, 0x34, 0xbd};
- CHECK(( toStdVector(Botan::base64_decode("gTS9")) == binary3 ));
+ CHECK_THAT(toStdVector(Botan::base64_decode("gTS9")), Equals(binary3));
std::vector<unsigned char> binary4 = {0x5e, 0x6c, 0xff, 0xde};
- CHECK(( toStdVector(Botan::base64_decode("Xmz/3g==")) == binary4 ));
+ CHECK_THAT(toStdVector(Botan::base64_decode("Xmz/3g==")), Equals(binary4));
std::vector<unsigned char> binary5 = {0xb2, 0xcd, 0xf0, 0xdc, 0x7f};
- CHECK(( toStdVector(Botan::base64_decode("ss3w3H8=")) == binary5 ));
+ CHECK_THAT(toStdVector(Botan::base64_decode("ss3w3H8=")), Equals(binary5));
std::vector<unsigned char> binary6 = {0xfc, 0x56, 0x2d, 0xda, 0xd4, 0x0e};
- CHECK(( toStdVector(Botan::base64_decode("/FYt2tQO")) == binary6 ));
+ CHECK_THAT(toStdVector(Botan::base64_decode("/FYt2tQO")), Equals(binary6));
std::vector<unsigned char> binary7 = {0x29, 0xb2, 0x32, 0x2e, 0x88, 0x41, 0xe8};
- CHECK(( toStdVector(Botan::base64_decode("KbIyLohB6A==")) == binary7 ));
+ CHECK_THAT(toStdVector(Botan::base64_decode("KbIyLohB6A==")), Equals(binary7));
std::vector<unsigned char> binary8 = {0x0f, 0x0f, 0xce, 0xd9, 0x49, 0x7a, 0xaf, 0x92};
- CHECK(( toStdVector(Botan::base64_decode("Dw/O2Ul6r5I=")) == binary8 ));
+ CHECK_THAT(toStdVector(Botan::base64_decode("Dw/O2Ul6r5I=")), Equals(binary8));
std::vector<unsigned char> binary9 = {0x27, 0x0f, 0xb1, 0x89, 0x82, 0x80, 0x0d, 0xa6, 0x40};
- CHECK(( toStdVector(Botan::base64_decode("Jw+xiYKADaZA")) == binary9 ));
+ CHECK_THAT(toStdVector(Botan::base64_decode("Jw+xiYKADaZA")), Equals(binary9));
}
TEST_CASE("Base64 decode and ignore whitespace", "[base64]")
{
- CHECK(( toStdVector(Botan::base64_decode(std::string(" Zg=="), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("Z g=="), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("Zg =="), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("Zg= ="), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("Zg== "), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("\rZg=="), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("\nZg=="), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("\tZg=="), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("Zg\r=="), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("Zg\n=="), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("Zg\t=="), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("Zg==\r"), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("Zg==\n"), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("Zg==\t"), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("\r Zg=="), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("\n Zg=="), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("\t Zg=="), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("Zg\r =="), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("Zg\n =="), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("Zg\t =="), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("Zg==\r "), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("Zg==\n "), true)) == toStdVector("f") ));
- CHECK(( toStdVector(Botan::base64_decode(std::string("Zg==\t "), true)) == toStdVector("f") ));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string(" Zg=="), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("Z g=="), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("Zg =="), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("Zg= ="), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("Zg== "), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("\rZg=="), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("\nZg=="), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("\tZg=="), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("Zg\r=="), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("Zg\n=="), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("Zg\t=="), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("Zg==\r"), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("Zg==\n"), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("Zg==\t"), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("\r Zg=="), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("\n Zg=="), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("\t Zg=="), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("Zg\r =="), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("Zg\n =="), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("Zg\t =="), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("Zg==\r "), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("Zg==\n "), true)), Equals(toStdVector("f")));
+ CHECK_THAT(toStdVector(Botan::base64_decode(std::string("Zg==\t "), true)), Equals(toStdVector("f")));
}
TEST_CASE("Base64 decode and don't ignore whitespace", "[base64]")
{
- CHECK_THROWS( Botan::base64_decode(std::string(" Zg=="), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("Z g=="), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("Zg =="), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("Zg= ="), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("Zg== "), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("\rZg=="), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("\nZg=="), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("\tZg=="), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("Zg\r=="), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("Zg\n=="), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("Zg\t=="), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("Zg==\r"), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("Zg==\n"), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("Zg==\t"), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("\r Zg=="), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("\n Zg=="), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("\t Zg=="), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("Zg\r =="), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("Zg\n =="), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("Zg\t =="), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("Zg==\r "), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("Zg==\n "), false) );
- CHECK_THROWS( Botan::base64_decode(std::string("Zg==\t "), false) );
+ CHECK_THROWS(Botan::base64_decode(std::string(" Zg=="), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("Z g=="), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("Zg =="), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("Zg= ="), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("Zg== "), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("\rZg=="), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("\nZg=="), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("\tZg=="), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("Zg\r=="), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("Zg\n=="), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("Zg\t=="), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("Zg==\r"), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("Zg==\n"), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("Zg==\t"), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("\r Zg=="), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("\n Zg=="), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("\t Zg=="), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("Zg\r =="), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("Zg\n =="), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("Zg\t =="), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("Zg==\r "), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("Zg==\n "), false));
+ CHECK_THROWS(Botan::base64_decode(std::string("Zg==\t "), false));
}
#endif // BOTAN_HAS_BASE64_CODEC
diff --git a/src/tests/catchy/test_cvc.cpp b/src/tests/catchy/test_cvc.cpp
index 1678f76f1..2ac6be848 100644
--- a/src/tests/catchy/test_cvc.cpp
+++ b/src/tests/catchy/test_cvc.cpp
@@ -1,8 +1,7 @@
// (C) 2015 Simon Warta (Kullo GmbH)
// Botan is released under the Simplified BSD License (see license.txt)
-#include "catch.hpp"
-#include <botan/build.h>
+#include "catchy_tests.h"
#if defined(BOTAN_HAS_CVC)
diff --git a/src/tests/catchy/test_stl_util.cpp b/src/tests/catchy/test_stl_util.cpp
index a0b38b045..f7c2c9990 100644
--- a/src/tests/catchy/test_stl_util.cpp
+++ b/src/tests/catchy/test_stl_util.cpp
@@ -1,8 +1,8 @@
// (C) 2015 Simon Warta (Kullo GmbH)
// Botan is released under the Simplified BSD License (see license.txt)
-#include "catch.hpp"
-#include <botan/types.h>
+#include "catchy_tests.h"
+
#include <botan/internal/stl_util.h>
TEST_CASE("secure vector to string", "[STL_Util]")
@@ -14,8 +14,8 @@ TEST_CASE("secure vector to string", "[STL_Util]")
// echo -n "ö" | hexdump -C
auto utf8 = secure_vector<byte>{ 0xc3, 0xb6 };
- CHECK(( to_string(empty) == "" ));
- CHECK(( to_string(one) == "^" ));
- CHECK(( to_string(some) == "Hello" ));
- CHECK(( to_string(utf8) == "ö" ));
+ CHECK_THAT(to_string(empty), Equals(""));
+ CHECK_THAT(to_string(one), Equals("^"));
+ CHECK_THAT(to_string(some), Equals("Hello"));
+ CHECK_THAT(to_string(utf8), Equals("ö"));
}
diff --git a/src/tests/catchy/test_utils.cpp b/src/tests/catchy/test_utils.cpp
index 702d82f9c..a04010b8f 100644
--- a/src/tests/catchy/test_utils.cpp
+++ b/src/tests/catchy/test_utils.cpp
@@ -1,7 +1,7 @@
// (C) 2015 Simon Warta (Kullo GmbH)
// Botan is released under the Simplified BSD License (see license.txt)
-#include "catch.hpp"
+#include "catchy_tests.h"
#include <botan/calendar.h>
#include <botan/internal/rounding.h>
diff --git a/src/tests/catchy/test_x509.cpp b/src/tests/catchy/test_x509.cpp
index 20b72ab26..01c01dbdc 100644
--- a/src/tests/catchy/test_x509.cpp
+++ b/src/tests/catchy/test_x509.cpp
@@ -1,8 +1,7 @@
// (C) 2015 Simon Warta (Kullo GmbH)
// Botan is released under the Simplified BSD License (see license.txt)
-#include "catch.hpp"
-#include <botan/build.h>
+#include "catchy_tests.h"
// deacticate due to
// https://github.com/randombit/botan/issues/185