Remove use of ASSERT_THAT

This commit is contained in:
Eelke Klein 2017-08-26 19:07:01 +02:00
parent 4c658d7811
commit 78a4c6d730
5 changed files with 53 additions and 54 deletions

View file

@ -19,7 +19,7 @@ TEST(CsvWriter, one_row_two_numbers)
writer.nextRow();
QString expected = QString::fromUtf8("1,2\n");
ASSERT_THAT(result, Eq(expected));
ASSERT_EQ(result, expected);
}
TEST(CsvWriter, one_row_one_number_one_unquoted_string)
@ -34,7 +34,7 @@ TEST(CsvWriter, one_row_one_number_one_unquoted_string)
writer.nextRow();
QString expected = QString::fromUtf8("1,hello\n");
ASSERT_THAT(result, Eq(expected));
ASSERT_EQ(result, expected);
}
TEST(CsvWriter, one_row_one_number_one_quoted_string)
@ -49,7 +49,7 @@ TEST(CsvWriter, one_row_one_number_one_quoted_string)
writer.nextRow();
QString expected = QString::fromUtf8("1,\"hel,lo\"\n");
ASSERT_THAT(result, Eq(expected));
ASSERT_EQ(result, expected);
}
TEST(CsvWriter, newline_in_field)
@ -64,7 +64,7 @@ TEST(CsvWriter, newline_in_field)
writer.nextRow();
QString expected = QString::fromUtf8("1,\"hel\nlo\"\n");
ASSERT_THAT(result, Eq(expected));
ASSERT_EQ(result, expected);
}
TEST(CsvWriter, escape_quote)
@ -79,7 +79,7 @@ TEST(CsvWriter, escape_quote)
writer.nextRow();
QString expected = QString::fromUtf8("1,\"hel\"\"lo\"\n");
ASSERT_THAT(result, Eq(expected));
ASSERT_EQ(result, expected);
}
TEST(CsvWriter, non_default_seperator)
@ -94,7 +94,7 @@ TEST(CsvWriter, non_default_seperator)
writer.nextRow();
QString expected = QString::fromUtf8("1\thel,lo\n");
ASSERT_THAT(result, Eq(expected));
ASSERT_EQ(result, expected);
}
TEST(CsvWriter, non_default_quote)
@ -109,5 +109,5 @@ TEST(CsvWriter, non_default_quote)
writer.nextRow();
QString expected = QString::fromUtf8("1\t*hel\tlo*\n");
ASSERT_THAT(result, Eq(expected));
ASSERT_EQ(result, expected);
}

View file

@ -11,7 +11,7 @@ TEST(PasswordManager, initial_changeMasterPassword_returns_true)
auto res = pwm.changeMasterPassword("", "my test passphrase");
ASSERT_NO_THROW( res.get() );
ASSERT_THAT( res.get(), Eq(true) );
ASSERT_TRUE(res.get());
}
TEST(PasswordManager, unlock_succeeds)
@ -22,11 +22,11 @@ TEST(PasswordManager, unlock_succeeds)
auto res = pwm.changeMasterPassword("", passphrase);
ASSERT_NO_THROW( res.get() );
ASSERT_THAT( res.get(), Eq(true) );
ASSERT_TRUE(res.get());
auto res2 = pwm.unlock(passphrase);
ASSERT_NO_THROW( res2.get() );
ASSERT_THAT( res2.get(), Eq(true) );
ASSERT_TRUE(res2.get());
}
TEST(PasswordManager, unlock_fails)
@ -36,12 +36,12 @@ TEST(PasswordManager, unlock_fails)
std::string passphrase = "my test passphrase";
auto res = pwm.changeMasterPassword("", passphrase);
ASSERT_NO_THROW( res.get() );
ASSERT_THAT( res.get(), Eq(true) );
ASSERT_NO_THROW(res.get());
ASSERT_TRUE(res.get());
auto res2 = pwm.unlock(passphrase + "2");
ASSERT_NO_THROW( res2.get() );
ASSERT_THAT( res2.get(), Eq(false) );
ASSERT_NO_THROW(res2.get());
ASSERT_FALSE(res2.get());
}
TEST(PasswordManager, test_save_get)
@ -52,7 +52,7 @@ TEST(PasswordManager, test_save_get)
auto res = pwm.changeMasterPassword("", passphrase);
ASSERT_NO_THROW( res.get() );
ASSERT_THAT( res.get(), Eq(true) );
ASSERT_TRUE(res.get());
// auto res2 = pwm.unlock(passphrase + "2");
// ASSERT_NO_THROW( res2.get() );
@ -62,12 +62,11 @@ TEST(PasswordManager, test_save_get)
const std::string key = "abc";
auto res2 = pwm.savePassword(key, password);
ASSERT_THAT( res2.valid(), Eq(true) );
ASSERT_TRUE(res2.valid());
std::string result;
auto res3 = pwm.getPassword(key, result);
ASSERT_THAT( res3.valid(), Eq(true) );
ASSERT_THAT( res3.get(), Eq(true) );
ASSERT_THAT( result, Eq(password) );
ASSERT_TRUE(res3.valid());
ASSERT_TRUE(res3.get());
ASSERT_EQ(result, password);
}

View file

@ -15,24 +15,24 @@ TEST(SqlLexer, lexer)
QString out;
lexer.nextBasicToken(startpos, length, tokentype, out);
ASSERT_THAT(startpos, Eq(1));
ASSERT_THAT(length, Eq(6));
ASSERT_THAT(tokentype, Eq(BasicTokenType::Symbol));
ASSERT_THAT( out, Eq(QString("SELECT")) );
ASSERT_EQ(startpos, 1);
ASSERT_EQ(length, 6);
ASSERT_EQ(tokentype, BasicTokenType::Symbol);
ASSERT_EQ( out, QString("SELECT") );
}
TEST(SqlLexer, lexer_quote_in_string)
{
QString input = " 'abc''def' ";
SqlLexer lexer(input, LexerState::Null);
QString input = " 'abc''def' ";
SqlLexer lexer(input, LexerState::Null);
int startpos, length;
BasicTokenType tokentype;
QString out;
lexer.nextBasicToken(startpos, length, tokentype, out);
int startpos, length;
BasicTokenType tokentype;
QString out;
lexer.nextBasicToken(startpos, length, tokentype, out);
ASSERT_THAT(startpos, Eq(1));
ASSERT_THAT(length, Eq(10));
ASSERT_THAT(tokentype, Eq(BasicTokenType::QuotedString));
ASSERT_EQ(startpos, 1);
ASSERT_EQ(length, 10);
ASSERT_EQ(tokentype, BasicTokenType::QuotedString);
}

View file

@ -9,25 +9,25 @@ Expected<int> getAnswerToEverything() { return 42; }
TEST(expected, valid_when_valid_returns_true)
{
Expected<int> v = getAnswerToEverything();
ASSERT_THAT(v.valid(), Eq(true));
ASSERT_TRUE(v.valid());
}
TEST(expected, get_when_valid_returns_value)
{
Expected<int> v = getAnswerToEverything();
ASSERT_THAT(v.get(), Eq(42));
ASSERT_EQ(v.get(), 42);
}
TEST(expected, hasException_when_valid_returns_false)
{
Expected<int> v = getAnswerToEverything();
ASSERT_THAT(v.hasException<std::exception>(), Eq(false));
ASSERT_FALSE(v.hasException<std::exception>());
}
TEST(expected, T_fromException_is_not_valid)
{
auto e = Expected<int>::fromException(std::runtime_error("hello"));
ASSERT_THAT(e.valid(), Eq(false));
ASSERT_FALSE(e.valid());
}
TEST(expected, T_fromException_get_thows)
@ -39,38 +39,38 @@ TEST(expected, T_fromException_get_thows)
TEST(expected, T_fromException_has_exception_true)
{
auto e = Expected<int>::fromException(std::runtime_error("hello"));
ASSERT_THAT(e.hasException<std::runtime_error>(), Eq(true));
ASSERT_TRUE(e.hasException<std::runtime_error>());
}
TEST(expected, T_fromException_has_exception_false)
{
auto e = Expected<int>::fromException(std::runtime_error("hello"));
ASSERT_THAT(e.hasException<std::logic_error>(), Eq(false));
ASSERT_FALSE(e.hasException<std::logic_error>());
}
TEST(expected, T_fromException_has_derived_exception)
{
auto e = Expected<int>::fromException(std::runtime_error("hello"));
ASSERT_THAT(e.hasException<std::exception>(), Eq(true));
ASSERT_TRUE(e.hasException<std::exception>());
}
TEST(expected, T_fromCode_is_valid)
{
auto e = Expected<int>::fromCode([]() -> int { return 42; });
ASSERT_THAT(e.valid(), Eq(true));
ASSERT_TRUE(e.valid());
}
TEST(expected, T_fromCode_get)
{
auto e = Expected<int>::fromCode([]() -> int { return 42; });
ASSERT_THAT(e.get(), Eq(42));
ASSERT_EQ(e.get(), 42);
}
TEST(expected, T_fromCode_E_is_not_valid)
{
auto e = Expected<int>::fromCode([]() -> int { throw std::runtime_error("hello"); });
ASSERT_THAT(e.valid(), Eq(false));
ASSERT_FALSE(e.valid());
}
TEST(expected, T_fromCode_E_get_thows)
@ -82,19 +82,19 @@ TEST(expected, T_fromCode_E_get_thows)
TEST(expected, T_fromCode_E_has_exception_true)
{
auto e = Expected<int>::fromCode([]() -> int { throw std::runtime_error("hello"); });
ASSERT_THAT(e.hasException<std::runtime_error>(), Eq(true));
ASSERT_TRUE(e.hasException<std::runtime_error>());
}
TEST(expected, T_fromCode_E_has_exception_false)
{
auto e = Expected<int>::fromCode([]() -> int { throw std::runtime_error("hello"); });
ASSERT_THAT(e.hasException<std::logic_error>(), Eq(false));
ASSERT_FALSE(e.hasException<std::logic_error>());
}
TEST(expected, T_fromCode_E_has_derived_exception)
{
auto e = Expected<int>::fromCode([]() -> int { throw std::runtime_error("hello"); });
ASSERT_THAT(e.hasException<std::exception>(), Eq(true));
ASSERT_TRUE(e.hasException<std::exception>());
}
//Expected<int> getIntWithStdRuntimeError() { return Expected<void>(); }
@ -105,7 +105,7 @@ Expected<void> getNothing() { return Expected<void>(); }
TEST(expected_void, valid_when_valid_returns_true)
{
Expected<void> v = getNothing();
ASSERT_THAT(v.valid(), Eq(true));
ASSERT_TRUE(v.valid());
}
TEST(expected_void, get_when_valid_returns_value)
@ -117,7 +117,7 @@ TEST(expected_void, get_when_valid_returns_value)
TEST(expected_void, hasException_when_valid_returns_false)
{
Expected<void> v = getNothing();
ASSERT_THAT(v.hasException<std::exception>(), Eq(false));
ASSERT_FALSE(v.hasException<std::exception>());
}

View file

@ -9,7 +9,7 @@ TEST(ScopeGuard, normal_run_fun_on_destruction_1)
{
bool result = false;
auto sg = scopeGuard([&result]() { result = true; });
ASSERT_THAT(result, Eq(false));
ASSERT_FALSE(result);
}
TEST(ScopeGuard, normal_run_fun_on_destruction_2)
@ -19,7 +19,7 @@ TEST(ScopeGuard, normal_run_fun_on_destruction_2)
auto sg = scopeGuard([&result]() { result = true; });
}
ASSERT_THAT(result, Eq(true));
ASSERT_TRUE(result);
}
TEST(ScopeGuard, dismiss)
@ -30,7 +30,7 @@ TEST(ScopeGuard, dismiss)
sg.dismiss();
}
ASSERT_THAT(result, Eq(false));
ASSERT_FALSE(result);
}
TEST(ScopeGuard, SCOPE_EXIT_macro_1)
@ -38,7 +38,7 @@ TEST(ScopeGuard, SCOPE_EXIT_macro_1)
bool result = false;
{
SCOPE_EXIT { result = true; };
ASSERT_THAT(result, Eq(false)); // prove previous statement hasn't run yet
ASSERT_FALSE(result); // prove previous statement hasn't run yet
}
}
@ -50,7 +50,7 @@ TEST(ScopeGuard, SCOPE_EXIT_macro_2)
SCOPE_EXIT { result = true; };
}
ASSERT_THAT(result, Eq(true));
ASSERT_TRUE(result);
}