summaryrefslogtreecommitdiff
path: root/src/sexpr/lexer_test.cpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-04-14 11:02:47 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-04-14 11:32:36 -0700
commit56e149a51562b9d2620bc9037a81735c29ea95af (patch)
tree3a4bd218f69c5cbfec0dd8dcada34413c0ddc715 /src/sexpr/lexer_test.cpp
parent1a1bfc8fd8a3613bf7d3c320dcaff29a9402f50c (diff)
downloadtmwa-56e149a51562b9d2620bc9037a81735c29ea95af.tar.gz
tmwa-56e149a51562b9d2620bc9037a81735c29ea95af.tar.bz2
tmwa-56e149a51562b9d2620bc9037a81735c29ea95af.tar.xz
tmwa-56e149a51562b9d2620bc9037a81735c29ea95af.zip
Ditch gcc 4.6 support
Diffstat (limited to 'src/sexpr/lexer_test.cpp')
-rw-r--r--src/sexpr/lexer_test.cpp84
1 files changed, 42 insertions, 42 deletions
diff --git a/src/sexpr/lexer_test.cpp b/src/sexpr/lexer_test.cpp
index ade79af..fbff0d8 100644
--- a/src/sexpr/lexer_test.cpp
+++ b/src/sexpr/lexer_test.cpp
@@ -40,69 +40,69 @@ io::FD string_pipe(ZString sz)
TEST(sexpr, escape)
{
- EXPECT_EQ(sexpr::escape('\0'), "\\x00");
- EXPECT_EQ(sexpr::escape('\x1f'), "\\x1f");
- EXPECT_EQ(sexpr::escape('\x20'), " ");
- EXPECT_EQ(sexpr::escape('\x7e'), "~");
- EXPECT_EQ(sexpr::escape('\x7f'), "\\x7f");
- EXPECT_EQ(sexpr::escape('\x80'), "\\x80");
- EXPECT_EQ(sexpr::escape('\xff'), "\\xff");
- EXPECT_EQ(sexpr::escape('\a'), "\\a");
- EXPECT_EQ(sexpr::escape('\b'), "\\b");
- EXPECT_EQ(sexpr::escape('\e'), "\\e");
- EXPECT_EQ(sexpr::escape('\f'), "\\f");
- //EXPECT_EQ(sexpr::escape('\n'), "\\n");
- EXPECT_EQ(sexpr::escape('\n'), "\n");
- EXPECT_EQ(sexpr::escape('\r'), "\\r");
- EXPECT_EQ(sexpr::escape('\t'), "\\t");
- EXPECT_EQ(sexpr::escape('\v'), "\\v");
- EXPECT_EQ(sexpr::escape('\\'), "\\\\");
- EXPECT_EQ(sexpr::escape('\"'), "\\\"");
+ EXPECT_EQ(sexpr::escape('\0'), "\\x00"_s);
+ EXPECT_EQ(sexpr::escape('\x1f'), "\\x1f"_s);
+ EXPECT_EQ(sexpr::escape('\x20'), " "_s);
+ EXPECT_EQ(sexpr::escape('\x7e'), "~"_s);
+ EXPECT_EQ(sexpr::escape('\x7f'), "\\x7f"_s);
+ EXPECT_EQ(sexpr::escape('\x80'), "\\x80"_s);
+ EXPECT_EQ(sexpr::escape('\xff'), "\\xff"_s);
+ EXPECT_EQ(sexpr::escape('\a'), "\\a"_s);
+ EXPECT_EQ(sexpr::escape('\b'), "\\b"_s);
+ EXPECT_EQ(sexpr::escape('\e'), "\\e"_s);
+ EXPECT_EQ(sexpr::escape('\f'), "\\f"_s);
+ //EXPECT_EQ(sexpr::escape('\n'), "\\n"_s);
+ EXPECT_EQ(sexpr::escape('\n'), "\n"_s);
+ EXPECT_EQ(sexpr::escape('\r'), "\\r"_s);
+ EXPECT_EQ(sexpr::escape('\t'), "\\t"_s);
+ EXPECT_EQ(sexpr::escape('\v'), "\\v"_s);
+ EXPECT_EQ(sexpr::escape('\\'), "\\\\"_s);
+ EXPECT_EQ(sexpr::escape('\"'), "\\\""_s);
- EXPECT_EQ(sexpr::escape("\x1f\x20\x7e\x7f\x80\xff\a\b\e\f\r\t\v\\\""),
- "\"\\x1f ~\\x7f\\x80\\xff\\a\\b\\e\\f\\r\\t\\v\\\\\\\"\"");
+ EXPECT_EQ(sexpr::escape("\x1f\x20\x7e\x7f\x80\xff\a\b\e\f\r\t\v\\\""_s),
+ "\"\\x1f ~\\x7f\\x80\\xff\\a\\b\\e\\f\\r\\t\\v\\\\\\\"\""_s);
}
TEST(sexpr, lexer)
{
io::LineSpan span;
- sexpr::Lexer lexer("<lexer-test1>", string_pipe(" foo( ) 123\"\" \n"));
+ sexpr::Lexer lexer("<lexer-test1>"_s, string_pipe(" foo( ) 123\"\" \n"_s));
EXPECT_EQ(lexer.peek(), sexpr::TOK_TOKEN);
- EXPECT_EQ(lexer.val_string(), "foo");
- EXPECT_EQ(lexer.span().message_str("error", "test"),
+ EXPECT_EQ(lexer.val_string(), "foo"_s);
+ EXPECT_EQ(lexer.span().message_str("error"_s, "test"_s),
"<lexer-test1>:1:2: error: test\n"
" foo( ) 123\"\" \n"
- " ^~~\n"
+ " ^~~\n"_s
);
lexer.adv();
EXPECT_EQ(lexer.peek(), sexpr::TOK_OPEN);
- EXPECT_EQ(lexer.span().message_str("error", "test"),
+ EXPECT_EQ(lexer.span().message_str("error"_s, "test"_s),
"<lexer-test1>:1:5: error: test\n"
" foo( ) 123\"\" \n"
- " ^\n"
+ " ^\n"_s
);
lexer.adv();
EXPECT_EQ(lexer.peek(), sexpr::TOK_CLOSE);
- EXPECT_EQ(lexer.span().message_str("error", "test"),
+ EXPECT_EQ(lexer.span().message_str("error"_s, "test"_s),
"<lexer-test1>:1:7: error: test\n"
" foo( ) 123\"\" \n"
- " ^\n"
+ " ^\n"_s
);
lexer.adv();
EXPECT_EQ(lexer.peek(), sexpr::TOK_TOKEN);
- EXPECT_EQ(lexer.val_string(), "123");
- EXPECT_EQ(lexer.span().message_str("error", "test"),
+ EXPECT_EQ(lexer.val_string(), "123"_s);
+ EXPECT_EQ(lexer.span().message_str("error"_s, "test"_s),
"<lexer-test1>:1:9: error: test\n"
" foo( ) 123\"\" \n"
- " ^~~\n"
+ " ^~~\n"_s
);
lexer.adv();
EXPECT_EQ(lexer.peek(), sexpr::TOK_STRING);
- EXPECT_EQ(lexer.val_string(), "");
- EXPECT_EQ(lexer.span().message_str("error", "test"),
+ EXPECT_EQ(lexer.val_string(), ""_s);
+ EXPECT_EQ(lexer.span().message_str("error"_s, "test"_s),
"<lexer-test1>:1:12: error: test\n"
" foo( ) 123\"\" \n"
- " ^~\n"
+ " ^~\n"_s
);
lexer.adv();
EXPECT_EQ(lexer.peek(), sexpr::TOK_EOF);
@@ -112,22 +112,22 @@ TEST(sexpr, lexbad)
{
{
io::LineSpan span;
- sexpr::Lexer lexer("<lexer-bad>", string_pipe("(\n"));
+ sexpr::Lexer lexer("<lexer-bad>"_s, string_pipe("(\n"_s));
EXPECT_EQ(lexer.peek(), sexpr::TOK_OPEN);
lexer.adv();
EXPECT_EQ(lexer.peek(), sexpr::TOK_ERROR);
}
for (ZString bad : {
- ZString(")\n"),
- ZString("\"\n"),
- ZString("'\n"),
- ZString("\\\n"),
- ZString("\"\\"),
- ZString("\"\\z\""),
+ ZString(")\n"_s),
+ ZString("\"\n"_s),
+ ZString("'\n"_s),
+ ZString("\\\n"_s),
+ ZString("\"\\"_s),
+ ZString("\"\\z\""_s),
})
{
io::LineSpan span;
- sexpr::Lexer lexer("<lexer-bad>", string_pipe(bad));
+ sexpr::Lexer lexer("<lexer-bad>"_s, string_pipe(bad));
EXPECT_EQ(lexer.peek(), sexpr::TOK_ERROR);
}
}