Skip to content

Commit

Permalink
Use EXPECT_DEATH_IF_SUPPORTED
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Oct 23, 2023
1 parent 75e976a commit 4165279
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions crypto/fipsmodule/bn/bn_assert_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <gtest/gtest.h>

TEST(BNAssertTest, assert_fits_in_bytes_large) {
TEST(BNAssertTest, Assert_fits_in_bytes_large) {
bssl::UniquePtr<BIGNUM> x(BN_new());
uint8_t input[255];
OPENSSL_memset(input, 0, sizeof(input));
Expand All @@ -20,12 +20,14 @@ TEST(BNAssertTest, assert_fits_in_bytes_large) {
for (size_t i = 255; i < 260; i++) {
bn_assert_fits_in_bytes(x.get(), i);
}
#ifndef NDEBUG
for (size_t i = 247; i < 255; i++) {
EXPECT_DEBUG_DEATH(bn_assert_fits_in_bytes(x.get(), i), "");
EXPECT_DEATH_IF_SUPPORTED(bn_assert_fits_in_bytes(x.get(), i), "");
}
#endif
}

TEST(BNAssertTest, assert_fits_in_bytes_small) {
TEST(BNAssertTest, Assert_fits_in_bytes_small) {
bssl::UniquePtr<BIGNUM> x(BN_new());
uint8_t input[8];
OPENSSL_memset(input, 0, sizeof(input));
Expand All @@ -37,12 +39,14 @@ TEST(BNAssertTest, assert_fits_in_bytes_small) {
for (size_t i = 3; i < 10; i++) {
bn_assert_fits_in_bytes(x.get(), i);
}
#ifndef NDEBUG
for (size_t i = 0; i < 3; i++) {
EXPECT_DEBUG_DEATH(bn_assert_fits_in_bytes(x.get(), i), "");
EXPECT_DEATH_IF_SUPPORTED(bn_assert_fits_in_bytes(x.get(), i), "");
}
#endif
}

TEST(BNAssertTest, assert_fits_in_bytes_zero) {
TEST(BNAssertTest, Assert_fits_in_bytes_zero) {
bssl::UniquePtr<BIGNUM> x(BN_new());
uint8_t input[8];
OPENSSL_memset(input, 0, sizeof(input));
Expand All @@ -53,7 +57,7 @@ TEST(BNAssertTest, assert_fits_in_bytes_zero) {
}
}

TEST(BNAssertTest, assert_fits_in_bytes_boundary) {
TEST(BNAssertTest, Assert_fits_in_bytes_boundary) {
bssl::UniquePtr<BIGNUM> x(BN_new());
uint8_t input[8];
OPENSSL_memset(input, 0, sizeof(input));
Expand All @@ -64,7 +68,9 @@ TEST(BNAssertTest, assert_fits_in_bytes_boundary) {
for (size_t i = 8; i < 18; i++) {
bn_assert_fits_in_bytes(x.get(), i);
}
#ifndef NDEBUG
for (size_t i = 0; i < 8; i++) {
EXPECT_DEBUG_DEATH(bn_assert_fits_in_bytes(x.get(), i), "");
EXPECT_DEATH_IF_SUPPORTED(bn_assert_fits_in_bytes(x.get(), i), "");
}
#endif
}

0 comments on commit 4165279

Please sign in to comment.