From 19e5f03de3c9556299b90ddc9eddd56d6370f725 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Fri, 24 Apr 2015 21:33:25 +0200 Subject: [PATCH] Simplified CipherTest --- test/implementations/encrypted/CipherTest.cpp | 36 +++++-------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/test/implementations/encrypted/CipherTest.cpp b/test/implementations/encrypted/CipherTest.cpp index a4385998..f7471d60 100644 --- a/test/implementations/encrypted/CipherTest.cpp +++ b/test/implementations/encrypted/CipherTest.cpp @@ -61,31 +61,15 @@ public: TYPED_TEST_CASE_P(CipherTest); -TYPED_TEST_P(CipherTest, Size_0) { - EXPECT_EQ(0, TypeParam::ciphertextSize(TypeParam::plaintextSize(0))); -} - -TYPED_TEST_P(CipherTest, Size_1) { - EXPECT_EQ(1, TypeParam::ciphertextSize(TypeParam::plaintextSize(1))); -} - -TYPED_TEST_P(CipherTest, Size_1024) { - EXPECT_EQ(1024, TypeParam::ciphertextSize(TypeParam::plaintextSize(1024))); - EXPECT_EQ(1024, TypeParam::plaintextSize(TypeParam::ciphertextSize(1024))); -} - -TYPED_TEST_P(CipherTest, Size_4096) { - EXPECT_EQ(4096, TypeParam::ciphertextSize(TypeParam::plaintextSize(4096))); - EXPECT_EQ(4096, TypeParam::plaintextSize(TypeParam::ciphertextSize(4096))); -} - -TYPED_TEST_P(CipherTest, Size_1048576) { - EXPECT_EQ(1048576, TypeParam::ciphertextSize(TypeParam::plaintextSize(1048576))); - EXPECT_EQ(1048576, TypeParam::plaintextSize(TypeParam::ciphertextSize(1048576))); -} - constexpr std::initializer_list SIZES = {0, 1, 100, 1024, 5000, 1048576, 20971520}; +TYPED_TEST_P(CipherTest, Size) { + for (auto size: SIZES) { + EXPECT_EQ(size, TypeParam::ciphertextSize(TypeParam::plaintextSize(size))); + EXPECT_EQ(size, TypeParam::plaintextSize(TypeParam::ciphertextSize(size))); + } +} + TYPED_TEST_P(CipherTest, EncryptThenDecrypt_Zeroes) { for (auto size: SIZES) { Data plaintext = this->CreateZeroes(size); @@ -122,11 +106,7 @@ TYPED_TEST_P(CipherTest, EncryptedSize) { } REGISTER_TYPED_TEST_CASE_P(CipherTest, - Size_0, - Size_1, - Size_1024, - Size_4096, - Size_1048576, + Size, EncryptThenDecrypt_Zeroes, EncryptThenDecrypt_Data, EncryptIsIndeterministic_Zeroes,