added catch2 for unit tests and first test in test/test.cpp

This commit is contained in:
Gulliver
2022-11-21 22:44:07 +01:00
parent 4d9f373d62
commit 7a525a85ce
3 changed files with 49 additions and 5 deletions

14
test/test.cpp Normal file
View File

@ -0,0 +1,14 @@
#include <catch2/catch_test_macros.hpp>
#include "model.hpp"
TEST_CASE( "PublicKey::to_json", "[to_json]" ) {
PublicKey k {"daaa63ddda38c189b8c49020c8276adbe0a695685a...",
"65537" };
auto json = k.to_json();
REQUIRE( json["modulus"].dump() == "\"" + k.modulus + "\"" );
REQUIRE( json["public_exponent"].dump() == "\"" + k.public_exponent+"\"" );
REQUIRE( json["type"].dump() == "\"rsa public key\"" );
REQUIRE( json.keys().size() == 3 );
}