public void U8EscapeSequenceIsExtracted() { String input = "\"" + @"some\UABCD1234string" + "\""; var parser = new BasicCStringScanner(input); Assert.Equal(new StringPart(5,10), parser.Next()); Assert.Equal(null, parser.Next()); }
public StringPart?Next() { while (!text.EndOfLine) { if (text.Char() == '\\') { return(BasicCStringScanner.ParseEscapeSequence(text)); } else if (text.Char() == '%') { // skip %% if (text.NChar() == '%') { text.Skip(2); continue; } StringPart part = new StringPart(); if (ParseFormatSpecifier(ref part)) { return(part); } } text.Next(); } return(null); }
public void EscapeInSingleQuotesIsExtracted() { String input = @"'some\rstring'"; var parser = new BasicCStringScanner(input); Assert.Equal(new StringPart(5,2), parser.Next()); Assert.Equal(null, parser.Next()); }
public void EscapedBackslashIsExtractedCorrectly() { String input = "\"" + @"some\\string" + "\""; var parser = new BasicCStringScanner(input); Assert.Equal(new StringPart(5,2), parser.Next()); Assert.Equal(null, parser.Next()); }
public void TwoSeparateEscapeSequencesAreExtracted() { String input = "\"" + @"some\rother\nstring" + "\""; var parser = new BasicCStringScanner(input); Assert.Equal(new StringPart(5,2), parser.Next()); Assert.Equal(new StringPart(12,2), parser.Next()); Assert.Equal(null, parser.Next()); }
public StringPart?Next() { while (!text.EndOfLine) { if (text.Char() == '\\') { return(BasicCStringScanner.ParseEscapeSequence(text)); } else if (text.Char() == '{' && text.NChar() == '{') { text.Next(); // skip it } else if (text.Char() == '{' && !isInterpolated) { StringPart part = new StringPart(); if (ParseFormatSpecifier(ref part)) { return(part); } } text.Next(); } return(null); }
public void NoEscapesReturnsNull() { String input = "\"some string\""; var parser = new BasicCStringScanner(input); Assert.Equal(null, parser.Next()); }