public void TestVbString() { SetTerminal(TerminalFactory.CreateVbString("String")); //VB has no escapes - so make sure term doesn't catch any escapes TryMatchDoubles(@"'00\a\b\t\n\v\f\r\\00' "); Assert.IsTrue((string)_token.Value == @"00\a\b\t\n\v\f\r\\00", "Failed to process string with \\ characters."); TryMatchDoubles("'abcd\nefg' "); Assert.IsTrue(_token.IsError(), "Failed to detect erroneous multi-line string."); TryMatchDoubles("'abcd''efg' "); // doubled quote should change to single Assert.IsTrue((string)_token.Value == "abcd\"efg", "Failed to process a string with doubled double-quote char."); //Test char suffix "c" TryMatchDoubles("'A'c "); Assert.IsTrue((char)_token.Value == 'A', "Failed to process a character"); TryMatchDoubles("''c "); Assert.IsTrue(_token.IsError(), "Failed to detect an error for an empty char."); TryMatchDoubles("'ab'C "); Assert.IsTrue(_token.IsError(), "Failed to detect error in multi-char sequence."); }
public void TestString_VB() { var parser = TestHelper.CreateParser(TerminalFactory.CreateVbString("String")); //VB has no escapes - so make sure term doesn't catch any escapes var token = parser.ParseInput(ReplaceQuotes(@"'00\a\b\t\n\v\f\r\\00' ")); Assert.IsTrue((string)token.Value == @"00\a\b\t\n\v\f\r\\00", "Failed to process string with \\ characters."); token = parser.ParseInput(ReplaceQuotes("'abcd\nefg' ")); Assert.IsTrue(token.IsError, "Failed to detect erroneous multi-line string."); token = parser.ParseInput(ReplaceQuotes("'abcd''efg' ")); Assert.IsTrue((string)token.Value == "abcd\"efg", "Failed to process a string with doubled double-quote char."); //Test char suffix "c" token = parser.ParseInput(ReplaceQuotes("'A'c ")); Assert.IsTrue((char)token.Value == 'A', "Failed to process a character"); token = parser.ParseInput(ReplaceQuotes("''c ")); Assert.IsTrue(token.IsError, "Failed to detect an error for an empty char."); token = parser.ParseInput(ReplaceQuotes("'ab'C ")); Assert.IsTrue(token.IsError, "Failed to detect error in multi-char sequence."); }