diff options
author | Simon Warta <[email protected]> | 2015-07-09 10:55:38 +0200 |
---|---|---|
committer | Simon Warta <[email protected]> | 2015-07-15 13:51:20 +0200 |
commit | bac65bbdd0f28804f0418d41bd63fa39c290c68d (patch) | |
tree | 10d9037a597c71693d5f98ff0d43bbf92d179048 /src/tests/catchy/test_cvc.cpp | |
parent | 87ba413dc3c3cc648bba99d42307fac749edbdcc (diff) |
Add tests: x509 (deactivated), cvc
Diffstat (limited to 'src/tests/catchy/test_cvc.cpp')
-rw-r--r-- | src/tests/catchy/test_cvc.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/tests/catchy/test_cvc.cpp b/src/tests/catchy/test_cvc.cpp new file mode 100644 index 000000000..1678f76f1 --- /dev/null +++ b/src/tests/catchy/test_cvc.cpp @@ -0,0 +1,41 @@ +// (C) 2015 Simon Warta (Kullo GmbH) +// Botan is released under the Simplified BSD License (see license.txt) + +#include "catch.hpp" +#include <botan/build.h> + +#if defined(BOTAN_HAS_CVC) + +#include <botan/eac_asn_obj.h> + +TEST_CASE("human readable time", "[EAC_Time]") + { + auto time1 = Botan::EAC_Time("2008-02-01"); + auto time2 = Botan::EAC_Time("2008/02/28"); + auto time3 = Botan::EAC_Time("2004-06-14"); + + CHECK(( time1.time_is_set() == true )); + CHECK(( time2.time_is_set() == true )); + CHECK(( time3.time_is_set() == true )); + + CHECK(( time1.readable_string() == "2008/02/01" )); + CHECK(( time2.readable_string() == "2008/02/28" )); + CHECK(( time3.readable_string() == "2004/06/14" )); + } + +TEST_CASE("no time", "[EAC_Time]") + { + auto time = Botan::EAC_Time(""); + CHECK(( time.time_is_set() == false )); + } + +TEST_CASE("invalis time", "[EAC_Time]") + { + CHECK_THROWS( Botan::EAC_Time(" ") ); + CHECK_THROWS( Botan::EAC_Time("2008`02-01") ); + CHECK_THROWS( Botan::EAC_Time("9999-02-01") ); + CHECK_THROWS( Botan::EAC_Time("2000-02-01 17") ); + CHECK_THROWS( Botan::EAC_Time("999921") ); + } + +#endif // BOTAN_HAS_CVC |