public void FormatSpecWithTypePrecisionAndAlignmentIsExtracted() { String input = "\"" + @"Value: {0,-3:x2}" + "\""; var parser = new CSharpStringScanner(input); Assert.Equal(new StringPart(8, 9, StringPartType.FormatSpecifier), parser.Next()); Assert.Equal(null, parser.Next()); }
public void X1EscapeSequenceIsExtracted() { String input = "\"" + @"some\x1string" + "\""; var parser = new CSharpStringScanner(input); Assert.Equal(new StringPart(5, 3), parser.Next()); Assert.Equal(null, parser.Next()); }
public void EscapeInSingleQuotesIsExtracted() { String input = @"'some\rstring'"; var parser = new CSharpStringScanner(input); Assert.Equal(new StringPart(5, 2), parser.Next()); Assert.Equal(null, parser.Next()); }
public void EscapedBackslashIsExtractedCorrectly() { String input = "\"" + @"some\\string" + "\""; var parser = new CSharpStringScanner(input); Assert.Equal(new StringPart(5, 2), parser.Next()); Assert.Equal(null, parser.Next()); }
public void FormatSpecsInVerbatimStringIsExtracted() { String input = "@\"" + @"Value: {0}" + "\""; var parser = new CSharpStringScanner(input); Assert.Equal(new StringPart(9, 3, StringPartType.FormatSpecifier), parser.Next()); Assert.Equal(null, parser.Next()); }
public void SimpleFormatSpecifierIsExtracted() { String input = "\"" + @"Hello {0}" + "\""; var parser = new CSharpStringScanner(input); Assert.Equal(new StringPart(7, 3, StringPartType.FormatSpecifier), parser.Next()); Assert.Equal(null, parser.Next()); }
public void FormatSpecWithTypeIsExtracted() { String input = "\"" + @"Value: {0:c}" + "\""; var parser = new CSharpStringScanner(input); Assert.Equal(new StringPart(8, 5, StringPartType.FormatSpecifier), parser.Next()); Assert.Equal(null, parser.Next()); }
public void EscapeSequenceAfterInterpolatedBlockIsExtracted() { String input = "$\"some{value}\\a\""; var parser = new CSharpStringScanner(input); Assert.Equal(new StringPart(13, 2), parser.Next()); Assert.Equal(null, parser.Next()); }
public void TwoSeparateEscapeSequencesAreExtracted() { String input = "\"" + @"some\rother\nstring" + "\""; var parser = new CSharpStringScanner(input); Assert.Equal(new StringPart(5, 2), parser.Next()); Assert.Equal(new StringPart(12, 2), parser.Next()); Assert.Equal(null, parser.Next()); }
public void EscapeSequenceInVerbatimInterpolatedStringIsIgnored() { String input = "$@\"some\\a value\""; var parser = new CSharpStringScanner(input); Assert.Equal(null, parser.Next()); }
public void NoSequencesInInterpolatedAtStringAreExtracted() { String input = "$@\"" + @"some\rother\nstring" + "\""; var parser = new CSharpStringScanner(input); Assert.Equal(null, parser.Next()); }
public void FormatSpecsInInterpolatedAtStringsAreIgnored() { String input = "$@\"" + @"Value: {0}" + "\""; var parser = new CSharpStringScanner(input); Assert.Equal(null, parser.Next()); }
public void IncompleteSpecIsIgnored() { String input = "\"" + @"Value: {0" + "\""; var parser = new CSharpStringScanner(input); Assert.Equal(null, parser.Next()); }
public void FormatSpecInDoubleBracesIsIgnored() { String input = "\"" + @"Value: {{0}}" + "\""; var parser = new CSharpStringScanner(input); Assert.Equal(null, parser.Next()); }
public void NoEscapesReturnsNull() { String input = "\"some string\""; var parser = new CSharpStringScanner(input); Assert.Equal(null, parser.Next()); }
public void EmptyFormatSpecIsIgnored() { String input = "\"" + @"Value: {}" + "\""; var parser = new CSharpStringScanner(input); Assert.Equal(null, parser.Next()); }
public void FormatSpecsWithSpacesIsIgnored() { String input = "\"" + @"Value: {some space}" + "\""; var parser = new CSharpStringScanner(input); Assert.Equal(null, parser.Next()); }
public void BracesInDifferentLinesAreIgnoredAsFormatSpecs() { String input = "\"public interface IBar\r\n" + "{\r\n" + " Task Foo();\r\n" + "}\""; var parser = new CSharpStringScanner(input); Assert.Equal(null, parser.Next()); }