forked from ToruNiina/toml11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_lex_key_comment.cpp
52 lines (44 loc) · 2.01 KB
/
test_lex_key_comment.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <toml/lexer.hpp>
#include "unit_test.hpp"
#include "test_lex_aux.hpp"
using namespace toml;
using namespace detail;
BOOST_AUTO_TEST_CASE(test_bare_key)
{
TOML11_TEST_LEX_ACCEPT(lex_key, "barekey", "barekey");
TOML11_TEST_LEX_ACCEPT(lex_key, "bare-key", "bare-key");
TOML11_TEST_LEX_ACCEPT(lex_key, "bare_key", "bare_key");
TOML11_TEST_LEX_ACCEPT(lex_key, "1234", "1234");
}
BOOST_AUTO_TEST_CASE(test_quoted_key)
{
TOML11_TEST_LEX_ACCEPT(lex_key, "\"127.0.0.1\"", "\"127.0.0.1\"");
TOML11_TEST_LEX_ACCEPT(lex_key, "\"character encoding\"", "\"character encoding\"");
// UTF-8 codepoint of characters that looks like "key" written upside down
TOML11_TEST_LEX_ACCEPT(lex_key, "\"\xCA\x8E\xC7\x9D\xCA\x9E\"",
"\"\xCA\x8E\xC7\x9D\xCA\x9E\"");
TOML11_TEST_LEX_ACCEPT(lex_key, "'key2'", "'key2'");
TOML11_TEST_LEX_ACCEPT(lex_key, "'quoted \"value\"'", "'quoted \"value\"'");
}
BOOST_AUTO_TEST_CASE(test_dotted_key)
{
TOML11_TEST_LEX_ACCEPT(lex_key, "physical.color", "physical.color");
TOML11_TEST_LEX_ACCEPT(lex_key, "physical.shape", "physical.shape");
TOML11_TEST_LEX_ACCEPT(lex_key, "x.y", "x.y");
TOML11_TEST_LEX_ACCEPT(lex_key, "x . y", "x . y");
TOML11_TEST_LEX_ACCEPT(lex_key, "x.y.z", "x.y.z");
TOML11_TEST_LEX_ACCEPT(lex_key, "x. y .z", "x. y .z");
TOML11_TEST_LEX_ACCEPT(lex_key, "x .y. z", "x .y. z");
TOML11_TEST_LEX_ACCEPT(lex_key, "x . y . z", "x . y . z");
TOML11_TEST_LEX_ACCEPT(lex_key, "x.y.z.w", "x.y.z.w");
TOML11_TEST_LEX_ACCEPT(lex_key, "x. y .z. w", "x. y .z. w");
TOML11_TEST_LEX_ACCEPT(lex_key, "x . y . z . w", "x . y . z . w");
TOML11_TEST_LEX_ACCEPT(lex_key, "site.\"google.com\"", "site.\"google.com\"");
}
BOOST_AUTO_TEST_CASE(test_comment)
{
TOML11_TEST_LEX_ACCEPT(lex_comment, "# hoge", "# hoge");
TOML11_TEST_LEX_ACCEPT(lex_comment, "# \n", "# ");
TOML11_TEST_LEX_ACCEPT(lex_comment, "# \r\n", "# ");
TOML11_TEST_LEX_ACCEPT(lex_comment, "# # \n", "# # ");
}