aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-12-06 11:05:16 -0500
committerJack Lloyd <[email protected]>2019-12-06 11:11:56 -0500
commitbbc71ebaa1573290f38273ca80b563d272c0917c (patch)
tree33e5a0eecb8db399b259d19283e3c8364cd27e02 /src/tests
parent9f3dbac2eb28906e53808682222aef4eb90f4c15 (diff)
Fix MSVC "optimization" warning about bool conversions
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/test_ocsp.cpp12
-rw-r--r--src/tests/unit_ecc.cpp2
-rw-r--r--src/tests/unit_ecdsa.cpp12
3 files changed, 13 insertions, 13 deletions
diff --git a/src/tests/test_ocsp.cpp b/src/tests/test_ocsp.cpp
index 5ccebdb41..94da76c95 100644
--- a/src/tests/test_ocsp.cpp
+++ b/src/tests/test_ocsp.cpp
@@ -151,7 +151,7 @@ class OCSP_Tests final : public Test
return result.test_eq("Expected size of ocsp_status", ocsp_status.size(), 1) &&
result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1) &&
result.confirm(std::string("Status: '") + Botan::to_string(expected) + "'",
- ocsp_status[0].count(expected));
+ ocsp_status[0].count(expected) > 0);
};
check_ocsp(Botan::calendar_point(2016, 11, 11, 12, 30, 0).to_std_timepoint(),
@@ -192,7 +192,7 @@ class OCSP_Tests final : public Test
return result.test_eq("Expected size of ocsp_status", ocsp_status.size(), 1) &&
result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1) &&
result.confirm(std::string("Status: '") + Botan::to_string(expected) + "'",
- ocsp_status[0].count(expected));
+ ocsp_status[0].count(expected) > 0);
};
check_ocsp(Botan::calendar_point(2016, 11, 11, 12, 30, 0).to_std_timepoint(),
@@ -233,7 +233,7 @@ class OCSP_Tests final : public Test
return result.test_eq("Expected size of ocsp_status", ocsp_status.size(), 1) &&
result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1) &&
result.confirm(std::string("Status: '") + Botan::to_string(expected) + "'",
- ocsp_status[0].count(expected));
+ ocsp_status[0].count(expected) > 0);
};
check_ocsp(Botan::calendar_point(2019, 5, 28, 7, 0, 0).to_std_timepoint(),
@@ -269,7 +269,7 @@ class OCSP_Tests final : public Test
return result.test_eq("Expected size of ocsp_status", ocsp_status.size(), 1) &&
result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1) &&
result.confirm(std::string("Status: '") + Botan::to_string(expected) + "'",
- ocsp_status[0].count(expected));
+ ocsp_status[0].count(expected) > 0);
};
check_ocsp(Botan::calendar_point(2019, 5, 28, 7, 0, 0).to_std_timepoint(),
@@ -306,7 +306,7 @@ class OCSP_Tests final : public Test
{
if(result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1))
{
- result.confirm("Status warning", ocsp_status[0].count(Botan::Certificate_Status_Code::OCSP_NO_REVOCATION_URL));
+ result.confirm("Status warning", ocsp_status[0].count(Botan::Certificate_Status_Code::OCSP_NO_REVOCATION_URL) > 0);
}
}
@@ -335,7 +335,7 @@ class OCSP_Tests final : public Test
{
if(result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1))
{
- result.confirm("Status ok", ocsp_status[0].count(Botan::Certificate_Status_Code::OCSP_RESPONSE_GOOD));
+ result.confirm("Status ok", ocsp_status[0].count(Botan::Certificate_Status_Code::OCSP_RESPONSE_GOOD) > 0);
}
}
diff --git a/src/tests/unit_ecc.cpp b/src/tests/unit_ecc.cpp
index 14236d8ae..459d6a594 100644
--- a/src/tests/unit_ecc.cpp
+++ b/src/tests/unit_ecc.cpp
@@ -52,7 +52,7 @@ Botan::BigInt test_integer(Botan::RandomNumberGenerator& rng, size_t bits, BigIn
return .01;
};
- bool active = rng.next_byte() % 2;
+ bool active = (rng.next_byte() > 128) ? true : false;
for(size_t i = 0; i != bits; ++i)
{
x <<= 1;
diff --git a/src/tests/unit_ecdsa.cpp b/src/tests/unit_ecdsa.cpp
index a103e67b0..23d03768a 100644
--- a/src/tests/unit_ecdsa.cpp
+++ b/src/tests/unit_ecdsa.cpp
@@ -215,7 +215,7 @@ Test::Result test_ecdsa_create_save_load()
Botan::DataSource_Memory pem_src(ecc_private_key_pem);
std::unique_ptr<Botan::Private_Key> loaded_key(Botan::PKCS8::load_key(pem_src, Test::rng()));
Botan::ECDSA_PrivateKey* loaded_ec_key = dynamic_cast<Botan::ECDSA_PrivateKey*>(loaded_key.get());
- result.confirm("the loaded key could be converted into an ECDSA_PrivateKey", loaded_ec_key);
+ result.confirm("the loaded key could be converted into an ECDSA_PrivateKey", loaded_ec_key != nullptr);
if(loaded_ec_key)
{
@@ -257,7 +257,7 @@ Test::Result test_unusual_curve()
Botan::DataSource_Memory key_data_src(key_odd_curve_str);
std::unique_ptr<Botan::Private_Key> loaded_key(Botan::PKCS8::load_key(key_data_src, Test::rng()));
- result.confirm("reloaded key", loaded_key.get());
+ result.confirm("reloaded key", loaded_key.get() != nullptr);
return result;
}
@@ -365,9 +365,9 @@ Test::Result test_ecc_key_with_rfc5915_extensions()
std::unique_ptr<Botan::Private_Key> pkcs8(
Botan::PKCS8::load_key(Test::data_file("x509/ecc/ecc_private_with_rfc5915_ext.pem"), Test::rng()));
- result.confirm("loaded RFC 5915 key", pkcs8.get());
+ result.confirm("loaded RFC 5915 key", pkcs8.get() != nullptr);
result.test_eq("key is ECDSA", pkcs8->algo_name(), "ECDSA");
- result.confirm("key type is ECDSA", dynamic_cast<Botan::ECDSA_PrivateKey*>(pkcs8.get()));
+ result.confirm("key type is ECDSA", dynamic_cast<Botan::ECDSA_PrivateKey*>(pkcs8.get()) != nullptr);
}
catch(std::exception& e)
{
@@ -386,9 +386,9 @@ Test::Result test_ecc_key_with_rfc5915_parameters()
std::unique_ptr<Botan::Private_Key> pkcs8(
Botan::PKCS8::load_key(Test::data_file("x509/ecc/ecc_private_with_rfc5915_parameters.pem"), Test::rng()));
- result.confirm("loaded RFC 5915 key", pkcs8.get());
+ result.confirm("loaded RFC 5915 key", pkcs8.get() != nullptr);
result.test_eq("key is ECDSA", pkcs8->algo_name(), "ECDSA");
- result.confirm("key type is ECDSA", dynamic_cast<Botan::ECDSA_PrivateKey*>(pkcs8.get()));
+ result.confirm("key type is ECDSA", dynamic_cast<Botan::ECDSA_PrivateKey*>(pkcs8.get()) != nullptr);
}
catch(std::exception& e)
{