annotate Implab.Test/Implab.Format.Test/JsonTests.cs @ 182:76e8f2ba12b8 ref20160224

pretty print DFA, the minimization is still buggy
author cin
date Thu, 24 Mar 2016 18:52:10 +0300
parents 130781364799
children 4f82e0f161c3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
158
130781364799 refactoring, code cleanup
cin
parents:
diff changeset
1 using NUnit.Framework;
130781364799 refactoring, code cleanup
cin
parents:
diff changeset
2 using System;
182
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
3 using Implab.Formats.JSON;
158
130781364799 refactoring, code cleanup
cin
parents:
diff changeset
4
130781364799 refactoring, code cleanup
cin
parents:
diff changeset
5 namespace Implab.Format.Test {
182
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
6 [TestFixture]
158
130781364799 refactoring, code cleanup
cin
parents:
diff changeset
7 public class JsonTests {
182
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
8 [Test]
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
9 public void TestScannerValidTokens() {
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
10 var scanner = new JSONScanner(@"9123, -123, 0, 0.1, -0.2, -0.1e3, 1.3E-3, ""some \t\n\u0020 text"", literal []{}:");
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
11
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
12 Tuple<JsonTokenType,object>[] expexted = new [] {
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
13 new Tuple<JsonTokenType,object>(JsonTokenType.Number, 9123d),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
14 new Tuple<JsonTokenType,object>(JsonTokenType.ValueSeparator, ", " ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
15 new Tuple<JsonTokenType,object>(JsonTokenType.Number, -123d ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
16 new Tuple<JsonTokenType,object>(JsonTokenType.ValueSeparator, ", " ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
17 new Tuple<JsonTokenType,object>(JsonTokenType.Number, 0d ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
18 new Tuple<JsonTokenType,object>(JsonTokenType.ValueSeparator, ", " ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
19 new Tuple<JsonTokenType,object>(JsonTokenType.Number, 0.1d ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
20 new Tuple<JsonTokenType,object>(JsonTokenType.ValueSeparator, ", " ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
21 new Tuple<JsonTokenType,object>(JsonTokenType.Number, -0.2d ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
22 new Tuple<JsonTokenType,object>(JsonTokenType.ValueSeparator, ", " ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
23 new Tuple<JsonTokenType,object>(JsonTokenType.Number, -0.1e3d ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
24 new Tuple<JsonTokenType,object>(JsonTokenType.ValueSeparator, ", " ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
25 new Tuple<JsonTokenType,object>(JsonTokenType.Number, 1.3E-3d ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
26 new Tuple<JsonTokenType,object>(JsonTokenType.ValueSeparator, ", " ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
27 new Tuple<JsonTokenType,object>(JsonTokenType.String, "some \t\n text" ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
28 new Tuple<JsonTokenType,object>(JsonTokenType.ValueSeparator, ", " ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
29 new Tuple<JsonTokenType,object>(JsonTokenType.Literal, "literal" ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
30 new Tuple<JsonTokenType,object>(JsonTokenType.BeginArray, " [" ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
31 new Tuple<JsonTokenType,object>(JsonTokenType.EndArray, "]" ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
32 new Tuple<JsonTokenType,object>(JsonTokenType.BeginObject, "{" ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
33 new Tuple<JsonTokenType,object>(JsonTokenType.EndObject, "}" ),
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
34 new Tuple<JsonTokenType,object>(JsonTokenType.NameSeparator, ":" )
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
35 };
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
36
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
37 object value;
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
38 JsonTokenType tokenType;
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
39 for (var i = 0; i < expexted.Length; i++) {
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
40
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
41 Assert.IsTrue(scanner.ReadToken(out value, out tokenType));
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
42 Assert.AreEqual(expexted[i].Item1, tokenType);
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
43 Assert.AreEqual(expexted[i].Item2, value);
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
44 }
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
45
76e8f2ba12b8 pretty print DFA, the minimization is still buggy
cin
parents: 158
diff changeset
46 Assert.IsFalse(scanner.ReadToken(out value, out tokenType));
158
130781364799 refactoring, code cleanup
cin
parents:
diff changeset
47 }
130781364799 refactoring, code cleanup
cin
parents:
diff changeset
48 }
130781364799 refactoring, code cleanup
cin
parents:
diff changeset
49 }
130781364799 refactoring, code cleanup
cin
parents:
diff changeset
50