add password hash test (#4528)

* clangify tests

* add password hash test

* properly use googletest semantics
This commit is contained in:
ebbit1q 2022-01-16 22:32:11 +01:00 committed by GitHub
parent f6634de18d
commit 1e70989f38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 125 additions and 81 deletions

View file

@ -1,25 +1,27 @@
#include "gtest/gtest.h"
#include "../common/expression.h"
#include "gtest/gtest.h"
#include <cmath>
#define TEST_EXPR(name,a,b) TEST(name, Works) { \
Expression exp(8); \
ASSERT_EQ(exp.parse(a), b) << a; \
}
#define TEST_EXPR(name, a, b) \
TEST(ExpressionTest, name) \
{ \
Expression exp(8); \
ASSERT_EQ(exp.parse(a), b) << a; \
}
namespace
{
TEST_EXPR(Number, "1", 1)
TEST_EXPR(Multiply, "2*2", 4)
TEST_EXPR(Whitespace, "3 * 3", 9)
TEST_EXPR(Powers, "2^8", 256)
TEST_EXPR(OrderOfOperations, "2+2*2", 6)
TEST_EXPR(Fn, "2*cos(1)", 2*cos(1))
TEST_EXPR(Variable, "x / 2", 4)
TEST_EXPR(Negative, "-2 * 2", -4)
TEST_EXPR(UnknownFnReturnsZero, "blah(22)", 0)
TEST_EXPR(Number, "1", 1)
TEST_EXPR(Multiply, "2*2", 4)
TEST_EXPR(Whitespace, "3 * 3", 9)
TEST_EXPR(Powers, "2^8", 256)
TEST_EXPR(OrderOfOperations, "2+2*2", 6)
TEST_EXPR(Fn, "2*cos(1)", 2 * cos(1))
TEST_EXPR(Variable, "x / 2", 4)
TEST_EXPR(Negative, "-2 * 2", -4)
TEST_EXPR(UnknownFnReturnsZero, "blah(22)", 0)
} // namespace
@ -27,4 +29,4 @@ int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
}