##// END OF EJS Templates
pretty print DFA, the minimization is still buggy
pretty print DFA, the minimization is still buggy

File last commit:

r182:76e8f2ba12b8 ref20160224
r182:76e8f2ba12b8 ref20160224
Show More
JsonTests.cs
50 lines | 2.6 KiB | text/x-csharp | CSharpLexer
cin
refactoring, code cleanup
r158 using NUnit.Framework;
using System;
cin
pretty print DFA, the minimization is still buggy
r182 using Implab.Formats.JSON;
cin
refactoring, code cleanup
r158
namespace Implab.Format.Test {
cin
pretty print DFA, the minimization is still buggy
r182 [TestFixture]
cin
refactoring, code cleanup
r158 public class JsonTests {
cin
pretty print DFA, the minimization is still buggy
r182 [Test]
public void TestScannerValidTokens() {
var scanner = new JSONScanner(@"9123, -123, 0, 0.1, -0.2, -0.1e3, 1.3E-3, ""some \t\n\u0020 text"", literal []{}:");
Tuple<JsonTokenType,object>[] expexted = new [] {
new Tuple<JsonTokenType,object>(JsonTokenType.Number, 9123d),
new Tuple<JsonTokenType,object>(JsonTokenType.ValueSeparator, ", " ),
new Tuple<JsonTokenType,object>(JsonTokenType.Number, -123d ),
new Tuple<JsonTokenType,object>(JsonTokenType.ValueSeparator, ", " ),
new Tuple<JsonTokenType,object>(JsonTokenType.Number, 0d ),
new Tuple<JsonTokenType,object>(JsonTokenType.ValueSeparator, ", " ),
new Tuple<JsonTokenType,object>(JsonTokenType.Number, 0.1d ),
new Tuple<JsonTokenType,object>(JsonTokenType.ValueSeparator, ", " ),
new Tuple<JsonTokenType,object>(JsonTokenType.Number, -0.2d ),
new Tuple<JsonTokenType,object>(JsonTokenType.ValueSeparator, ", " ),
new Tuple<JsonTokenType,object>(JsonTokenType.Number, -0.1e3d ),
new Tuple<JsonTokenType,object>(JsonTokenType.ValueSeparator, ", " ),
new Tuple<JsonTokenType,object>(JsonTokenType.Number, 1.3E-3d ),
new Tuple<JsonTokenType,object>(JsonTokenType.ValueSeparator, ", " ),
new Tuple<JsonTokenType,object>(JsonTokenType.String, "some \t\n text" ),
new Tuple<JsonTokenType,object>(JsonTokenType.ValueSeparator, ", " ),
new Tuple<JsonTokenType,object>(JsonTokenType.Literal, "literal" ),
new Tuple<JsonTokenType,object>(JsonTokenType.BeginArray, " [" ),
new Tuple<JsonTokenType,object>(JsonTokenType.EndArray, "]" ),
new Tuple<JsonTokenType,object>(JsonTokenType.BeginObject, "{" ),
new Tuple<JsonTokenType,object>(JsonTokenType.EndObject, "}" ),
new Tuple<JsonTokenType,object>(JsonTokenType.NameSeparator, ":" )
};
object value;
JsonTokenType tokenType;
for (var i = 0; i < expexted.Length; i++) {
Assert.IsTrue(scanner.ReadToken(out value, out tokenType));
Assert.AreEqual(expexted[i].Item1, tokenType);
Assert.AreEqual(expexted[i].Item2, value);
}
Assert.IsFalse(scanner.ReadToken(out value, out tokenType));
cin
refactoring, code cleanup
r158 }
}
}