public ParserTests() { _parser = new SmartFormatter().Parser; _parser.UseAlternativeEscapeChar(); _parser.AddAlphanumericSelectors(); _parser.AddAdditionalSelectorChars("_-"); _parser.AddOperators(".?,[]"); }
public FormatTests() { _literalFormatter = new SmartFormatter(); _literalFormatter.AddExtensions( new DefaultSource(_literalFormatter) ); _literalFormatter.AddExtensions( new DefaultFormatter() ); _placeholderFormat = new FormatCache(_parser.ParseFormat("{0}", _literalFormatter.GetNotEmptyFormatterExtensionNames())); _placeholder0005Format = new FormatCache(_parser.ParseFormat("{0}{1}{2}{3}{4}", _literalFormatter.GetNotEmptyFormatterExtensionNames())); _literal0010CharFormat = new FormatCache(_parser.ParseFormat("1234567890", _literalFormatter.GetNotEmptyFormatterExtensionNames())); _literal3000CharFormat = new FormatCache(_parser.ParseFormat(LoremIpsum, _literalFormatter.GetNotEmptyFormatterExtensionNames())); _literal6000PlaceholderFormat = new FormatCache(_parser.ParseFormat(LoremIpsum + "{0}" + LoremIpsum, _literalFormatter.GetNotEmptyFormatterExtensionNames())); _literal18kEscPlaceholderFormat = new FormatCache(_parser.ParseFormat(LoremIpsum + @"\n" + LoremIpsum + "{0}" + LoremIpsum, _literalFormatter.GetNotEmptyFormatterExtensionNames())); _parser.UseAlternativeEscapeChar(); _parser.AddAlphanumericSelectors(); _parser.AddAdditionalSelectorChars("_-"); _parser.AddOperators(".?,[]"); }
public void TestParser() { var parser = new Parser(ErrorAction.ThrowError); parser.AddAlphanumericSelectors(); parser.AddAdditionalSelectorChars("_"); parser.AddOperators("."); var formats = new[] { " aaa {bbb.ccc: ddd {eee} fff } ggg ", "{aaa} {bbb}", "{}", "{a:{b:{c:{d} } } }", "{a}", " aaa {bbb_bbb.CCC} ddd ", }; var results = formats.Select(f => new { format = f, parsed = parser.ParseFormat(f) }).ToArray(); // Verify that the reconstructed formats // match the original ones: results.TryAll(r => Assert.AreEqual(r.format, r.parsed.ToString())).ThrowIfNotEmpty(); }