diff options
author | Jack Lloyd <[email protected]> | 2017-06-04 05:27:34 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-06-04 05:27:34 -0400 |
commit | 35300742dc496a74c7a700259de7b1f400d782e7 (patch) | |
tree | 15c796d08f750f53ef6990213bf26917b8c2339f /src/tests/test_tpm.cpp | |
parent | d6e7c9ea7f029026d84ce2828a26310dd9882679 (diff) |
Add basic test for TPM UUID class
Constify some member functions
Diffstat (limited to 'src/tests/test_tpm.cpp')
-rw-r--r-- | src/tests/test_tpm.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/tests/test_tpm.cpp b/src/tests/test_tpm.cpp index 039dd2551..267af4e89 100644 --- a/src/tests/test_tpm.cpp +++ b/src/tests/test_tpm.cpp @@ -8,6 +8,7 @@ #if defined(BOTAN_HAS_TPM) #include <botan/tpm.h> + #include <botan/uuid.h> #endif namespace Botan_Tests { @@ -80,6 +81,34 @@ class TPM_Tests : public Test BOTAN_REGISTER_TEST("tpm", TPM_Tests); +class UUID_Tests : public Test + { + public: + std::vector<Test::Result> run() override + { + Test::Result result("UUID"); + + const Botan::UUID empty_uuid; + + result.test_eq("Uninitialized UUID not valid", empty_uuid.is_valid(), false); + + const Botan::UUID random_uuid(Test::rng()); + result.test_eq("Random UUID is valid", empty_uuid.is_valid(), false); + + const Botan::UUID binary_copy(random_uuid.binary_value()); + result.confirm("UUID copied by binary equals original", random_uuid == binary_copy); + + std::string uuid_str = random_uuid.to_string(); + + const Botan::UUID string_copy(random_uuid.to_string()); + result.confirm("UUID copied by string equals original", random_uuid == string_copy); + + return {result}; + } + }; + +BOTAN_REGISTER_TEST("tpm_uuid", UUID_Tests); + #endif } |