Skip to content

Commit

Permalink
Add failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smoogipoo committed Aug 1, 2024
1 parent 07256c6 commit b3f05be
Showing 1 changed file with 55 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,68 @@ public void TestEmptyString(string input)
[InlineData("😊😊", "\"😊😊\"")]
[InlineData("hello\nworld", "'hello\nworld'")]
[InlineData("hello\nworld", "\"hello\nworld\"")]
[InlineData("hello\nworld", "\"hello\\nworld\"")]
public void TestBasicString(string expected, string input)
{
Assert.Equal(expected, parse(input));
}

[Theory]
// \'
[InlineData("\\'", "\"\\'\"")]
[InlineData("'", "'\\''")]
// \\
[InlineData("\\", "\"\\\\\"")]
[InlineData("\\", "'\\\\'")]
// \n
[InlineData("\n", "\"\\n\"")]
[InlineData("\\n", "'\\n'")]
// \r
[InlineData("\r", "\"\\r\"")]
[InlineData("\\r", "'\\r'")]
// \t
[InlineData("\t", "\"\\t\"")]
[InlineData("\\t", "'\\t'")]
// \v
[InlineData("\v", "\"\\v\"")]
[InlineData("\\v", "'\\v'")]
// \e
[InlineData("\x1B", "\"\\e\"")]
[InlineData("\\e", "'\\e'")]
// \f
[InlineData("\f", "\"\\f\"")]
[InlineData("\\f", "'\\f'")]
// \$
[InlineData("$", "\"\\$\"")]
[InlineData("\\$", "'\\$'")]
// \"
[InlineData("\"", "\"\\\"\"")]
[InlineData("\\\"", "'\\\"'")]
// \[0-7]{1,3}
[InlineData("A", "\"\\101\"")]
[InlineData("\\101", "'\\101'")]
[InlineData("AB", "\"\\101\\102\"")]
[InlineData("\\101\\102", "'\\101\\102'")]
[InlineData("\0", "\"\\400\"")]
[InlineData("\\400", "'\\400'")]
[InlineData("\\800", "\"\\800\"")]
[InlineData("\\800", "'\\800'")]
// \x[0-9A-Fa-f]{1,2}
[InlineData("A", "\"\\x41\"")]
[InlineData("\\x41", "'\\x41'")]
[InlineData("AB", "\"\\x41\\x42\"")]
[InlineData("\\x41\\x42", "'\\x41\\x42'")]
// \u{[0-9A-Fa-f]+}
[InlineData("A", "\"\\u{41}\"")]
[InlineData("\\u{41}", "'\\u{41}'")]
[InlineData("AB", "\"\\u{41}\\u{42}\"")]
[InlineData("\\u{41}\\u{42}", "'\\u{41}\\u{42}'")]
// Invalid escape sequence
[InlineData("\\g", "\"\\g\"")]
[InlineData("\\g", "'\\g'")]
// Other escaped strings
[InlineData(":username's data", "':username\\'s data'")]
[InlineData(":username's data", "\":username\\'s data\"")]
[InlineData(":username\\'s data", "\":username\\'s data\"")]
[InlineData("\"escaped\" quotes", "\"\\\"escaped\\\" quotes\"")]
public void TestEscapedString(string expected, string input)
{
Expand Down

0 comments on commit b3f05be

Please sign in to comment.