From b2d31e4bc77c9bb707bdf5ad3f76882a07134721 Mon Sep 17 00:00:00 2001 From: Simon Warta <simon@warta.it> Date: Sat, 8 Aug 2015 18:05:19 +0200 Subject: Test implicit X509_Time copy constructor and assignment --- src/tests/catchy/test_x509.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/tests/catchy') diff --git a/src/tests/catchy/test_x509.cpp b/src/tests/catchy/test_x509.cpp index ad4aa1b1b..448e06847 100644 --- a/src/tests/catchy/test_x509.cpp +++ b/src/tests/catchy/test_x509.cpp @@ -8,6 +8,7 @@ #include <botan/asn1_time.h> using namespace Botan; +using namespace Catch; TEST_CASE("human readable time", "[X509]") { @@ -24,6 +25,22 @@ TEST_CASE("human readable time", "[X509]") CHECK_THAT(time3.readable_string(), Equals("2004/06/14 23:34:30 UTC")); } +TEST_CASE("Implicit copy constructor", "[X509]") + { + auto time_orig = X509_Time("0802010000Z", ASN1_Tag::UTC_TIME); + auto time_copy = time_orig; + + // Check that implicit copy and assignment work: + // time_copy and time_orig must have the same data but + // must sit at different places in memory + CHECK((time_orig == time_copy)); + + auto address1 = reinterpret_cast<uintptr_t>(&time_orig); + auto address2 = reinterpret_cast<uintptr_t>(&time_copy); + + CHECK_THAT(address1, Not(Equals(address2))); + } + TEST_CASE("no time", "[X509]") { auto time = X509_Time(); -- cgit v1.2.3