Started adding unit tests

This commit is contained in:
2021-11-21 22:46:19 +01:00
parent ad737f1c73
commit 5a4b9e3298
9 changed files with 83 additions and 1 deletions

2
test/src/format.cpp Normal file
View File

@@ -0,0 +1,2 @@
#include <format.h>
#include <gtest/gtest.h>

18
test/src/parse.cpp Normal file
View File

@@ -0,0 +1,18 @@
#include <gtest/gtest.h>
#include <parse.h>
TEST(Parse, ast_node) {
ast_node_t ast_node1{'a'};
ast_node_t ast_node2{'a'};
ast_node_t ast_node3{'b'};
EXPECT_EQ(ast_node1 == ast_node2, true);
EXPECT_EQ(ast_node1 == ast_node3, false);
}
TEST(Parse, chars_only) {
constexpr std::array<ast_node_t, 8> control = {'a', 'b', 'c', 'd',
'e', 'f', 'g', 'h'};
EXPECT_EQ(detail::parse_string<"abcdefgh">().value, control);
}

9
test/src/utility.cpp Normal file
View File

@@ -0,0 +1,9 @@
#include <utility.h>
#include <gtest/gtest.h>
TEST(Utility, const_pow) {
EXPECT_EQ(detail::const_pow(10, 0), 1);
EXPECT_EQ(detail::const_pow(0, 1), 0);
EXPECT_EQ(detail::const_pow(2, 8), 0b1'0000'0000);
}