Fix test cases
This commit is contained in:
parent
7b269a1184
commit
1f86f83ca1
@ -2,9 +2,7 @@
|
|||||||
#include "../../../crypto/kdf/DerivedKey.h"
|
#include "../../../crypto/kdf/DerivedKey.h"
|
||||||
#include "../../../data/DataFixture.h"
|
#include "../../../data/DataFixture.h"
|
||||||
|
|
||||||
using namespace cryfs;
|
using namespace cpputils;
|
||||||
using cpputils::DataFixture;
|
|
||||||
using cpputils::Data;
|
|
||||||
|
|
||||||
TEST(DerivedKeyTest, Config) {
|
TEST(DerivedKeyTest, Config) {
|
||||||
DerivedKey<32> key(DerivedKeyConfig(DataFixture::generate(32, 1), 1024, 8, 16), DataFixture::generateFixedSize<32>(2));
|
DerivedKey<32> key(DerivedKeyConfig(DataFixture::generate(32, 1), 1024, 8, 16), DataFixture::generateFixedSize<32>(2));
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "../../../crypto/kdf/Scrypt.h"
|
#include "../../../crypto/kdf/Scrypt.h"
|
||||||
#include "testutils/SCryptTestSettings.h"
|
#include "testutils/SCryptTestSettings.h"
|
||||||
|
|
||||||
using namespace cryfs;
|
using namespace cpputils;
|
||||||
|
|
||||||
TEST(SCryptTest, GeneratedKeyIsReproductible_448) {
|
TEST(SCryptTest, GeneratedKeyIsReproductible_448) {
|
||||||
auto created = SCrypt().generateKey<56, SCryptTestSettings>("mypassword");
|
auto created = SCrypt().generateKey<56, SCryptTestSettings>("mypassword");
|
||||||
|
@ -14,7 +14,7 @@ using namespace cpputils;
|
|||||||
|
|
||||||
class FixedSizeDataTest: public Test {
|
class FixedSizeDataTest: public Test {
|
||||||
public:
|
public:
|
||||||
static constexpr unsigned int SIZE = 16;
|
static constexpr size_t SIZE = 16;
|
||||||
|
|
||||||
const string DATA1_AS_STRING = "1491BB4932A389EE14BC7090AC772972";
|
const string DATA1_AS_STRING = "1491BB4932A389EE14BC7090AC772972";
|
||||||
const string DATA2_AS_STRING = "272EE5517627CFA147A971A8E6E747E0";
|
const string DATA2_AS_STRING = "272EE5517627CFA147A971A8E6E747E0";
|
||||||
@ -24,14 +24,14 @@ public:
|
|||||||
|
|
||||||
FixedSizeDataTest() : DATA3_AS_BINARY(DataFixture::generate(SIZE, 1)), DATA4_AS_BINARY(DataFixture::generate(SIZE, 2)) {}
|
FixedSizeDataTest() : DATA3_AS_BINARY(DataFixture::generate(SIZE, 1)), DATA4_AS_BINARY(DataFixture::generate(SIZE, 2)) {}
|
||||||
|
|
||||||
template<unsigned int SIZE>
|
template<size_t SIZE>
|
||||||
void EXPECT_DATA_EQ(const Data &expected, const FixedSizeData<SIZE> &actual) {
|
void EXPECT_DATA_EQ(const Data &expected, const FixedSizeData<SIZE> &actual) {
|
||||||
EXPECT_EQ(expected.size(), SIZE);
|
EXPECT_EQ(expected.size(), SIZE);
|
||||||
EXPECT_EQ(0, std::memcmp(expected.data(), actual.data(), SIZE));
|
EXPECT_EQ(0, std::memcmp(expected.data(), actual.data(), SIZE));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr unsigned int FixedSizeDataTest::SIZE;
|
constexpr size_t FixedSizeDataTest::SIZE;
|
||||||
|
|
||||||
TEST_F(FixedSizeDataTest, EqualsTrue) {
|
TEST_F(FixedSizeDataTest, EqualsTrue) {
|
||||||
FixedSizeData<SIZE> DATA1_1 = FixedSizeData<SIZE>::FromString(DATA1_AS_STRING);
|
FixedSizeData<SIZE> DATA1_1 = FixedSizeData<SIZE>::FromString(DATA1_AS_STRING);
|
||||||
|
@ -68,9 +68,11 @@ void logAndExit(const string &message) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using LoggingTest_DeathTest = LoggingTest;
|
||||||
|
|
||||||
// fork() only forks the main thread. This test ensures that logging doesn't depend on threads that suddenly aren't
|
// fork() only forks the main thread. This test ensures that logging doesn't depend on threads that suddenly aren't
|
||||||
// there anymore after a fork().
|
// there anymore after a fork().
|
||||||
TEST_F(LoggingTest, LoggingAlsoWorksAfterFork) {
|
TEST_F(LoggingTest_DeathTest, LoggingAlsoWorksAfterFork) {
|
||||||
setLogger(spdlog::stderr_logger_mt("StderrLogger"));
|
setLogger(spdlog::stderr_logger_mt("StderrLogger"));
|
||||||
EXPECT_EXIT(
|
EXPECT_EXIT(
|
||||||
logAndExit("My log message"),
|
logAndExit("My log message"),
|
||||||
|
Loading…
Reference in New Issue
Block a user