Moved parse_types into namespace detail; Added test Parse_ast_nodes_only
This commit is contained in:
parent
5a4b9e3298
commit
7b5290983a
@ -2,6 +2,9 @@
|
||||
#define LOGGER_PARSE_TYPES_H
|
||||
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
||||
enum class FormatType { s, c, b, B, d, o, x, X, a, A, e, E, f, F, g, G, p };
|
||||
|
||||
|
||||
@ -47,6 +50,7 @@ public:
|
||||
m_c = c;
|
||||
m_is_char = true;
|
||||
}
|
||||
|
||||
constexpr void set_node(fmt_node_t node) {
|
||||
m_node = node;
|
||||
m_is_char = false;
|
||||
@ -55,6 +59,7 @@ public:
|
||||
constexpr char get_char() const {
|
||||
return m_c;
|
||||
}
|
||||
|
||||
constexpr fmt_node_t get_node() const {
|
||||
return m_node;
|
||||
}
|
||||
@ -73,4 +78,7 @@ template <std::size_t N>
|
||||
using string_result_t = std::array<ast_node_t, N>;
|
||||
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
#endif // LOGGER_PARSE_TYPES_H
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <parse.h>
|
||||
|
||||
|
||||
using namespace detail;
|
||||
|
||||
|
||||
TEST(Parse, ast_node) {
|
||||
ast_node_t ast_node1{'a'};
|
||||
ast_node_t ast_node2{'a'};
|
||||
@ -10,9 +14,32 @@ TEST(Parse, ast_node) {
|
||||
EXPECT_EQ(ast_node1 == ast_node3, false);
|
||||
}
|
||||
|
||||
TEST(Parse, chars_only) {
|
||||
TEST(Parse, ast_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);
|
||||
EXPECT_EQ(parse_string<"abcdefgh">().value, control);
|
||||
}
|
||||
|
||||
TEST(Parse, ast_nodes_only) {
|
||||
fmt_node_t fmt_node0 = {true, 6, 3, FormatType::s};
|
||||
|
||||
fmt_node_t fmt_node1;
|
||||
fmt_node1.length = 8;
|
||||
fmt_node1.type = FormatType::s;
|
||||
|
||||
fmt_node_t fmt_node2;
|
||||
fmt_node2.precision = 4;
|
||||
|
||||
fmt_node_t fmt_node3 = {};
|
||||
fmt_node_t fmt_node4 = {};
|
||||
fmt_node_t fmt_node5 = {};
|
||||
fmt_node_t fmt_node6 = {};
|
||||
fmt_node_t fmt_node7 = {};
|
||||
|
||||
std::array<ast_node_t, 8> control = {
|
||||
fmt_node0, fmt_node1, fmt_node2, fmt_node3,
|
||||
fmt_node4, fmt_node5, fmt_node6, fmt_node7};
|
||||
|
||||
EXPECT_EQ(parse_string<"{:06.3}{:8s}{:.4}{}{}{}{}{}">().value, control);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user