public static Scanner PrepareScanner(string s) { var reader = new StringsReader(s); var scanner = new Scanner(reader); return(scanner); }
public void StringWithContent_stringReaderReadsFirstSignOnInitialization_CurrentSignCorrect() { // prepare var str = "example 123"; // act var stringReader = new StringsReader(str); // validate Assert.Equal('e', stringReader.CurrentSign); }
public void EmptyFile_stringReaderReadsFirstSignOnInitialization_CurrentSignMinusOne() { // prepare var str = ""; // act var stringReader = new StringsReader(str); // validate Assert.Equal(-1, stringReader.CurrentSign); }
public void FileWithContent_stringReaderReadsTwoSigns_CurrentSignCorrect() { // prepare var str = "example 123"; // act var stringReader = new StringsReader(str); stringReader.Read(); stringReader.Read(); // validate Assert.Equal('a', stringReader.CurrentSign); }
public void StreamWithStringWithEscapedQuoteMark_ReadNextTokenTillEof_TokensAreCorrect() { // prepare var reader = new StringsReader("\"st\\\"ring\""); var scanner = new Scanner(reader); // act scanner.ReadNextToken(); var firstToken = scanner.Token; var isString = scanner.TryReadString(); var secondToken = scanner.Token; scanner.ReadNextToken(); var thirdToken = scanner.Token; // validate Assert.Equal(TokenType.QuotationMark, firstToken.Type); Assert.Equal(TokenType.Text, secondToken.Type); Assert.Equal("st\"ring", secondToken.Value); Assert.Equal(TokenType.QuotationMark, thirdToken.Type); }