This repository was archived by the owner on Apr 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathObjectTests.cs
87 lines (76 loc) · 2.49 KB
/
ObjectTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Json5.Tests.Stringifying
{
[TestClass]
public class ObjectTests
{
[TestMethod]
public void EmptyObjectsTest()
{
var s = Json5.Stringify(new Json5Object());
Assert.AreEqual("{}", s);
}
[TestMethod]
public void UnquotedPropertyNamesTest()
{
var s = Json5.Stringify(new Json5Object { { "a", 1 } });
Assert.AreEqual("{a:1}", s);
}
[TestMethod]
public void SingleQuotedStringPropertyNamesTest()
{
var s = Json5.Stringify(new Json5Object { { "'a-b'", 1 } });
Assert.AreEqual("{'a-b':1}", s);
}
[TestMethod]
public void DoubleQuotedStringPropertyNamesTest()
{
var s = Json5.Stringify(new Json5Object { { "a'", 1 } });
Assert.AreEqual("{\"a'\":1}", s);
}
[TestMethod]
public void EmptyStringPropertyNamesTest()
{
var s = Json5.Stringify(new Json5Object { { "", 1 } });
Assert.AreEqual("{'':1}", s);
}
[TestMethod]
public void SpecialCharacterPropertyNamesTest()
{
var s = Json5.Stringify(new Json5Object { { "$_", 1 }, { "_$", 2 }, { "a\u200C", 3 } });
Assert.AreEqual("{$_:1,_$:2,a\u200C:3}", s);
}
[TestMethod]
public void UnicodePropertyNamesTest()
{
var s = Json5.Stringify(new Json5Object { { "ùńîċõďë", 9 } });
Assert.AreEqual("{ùńîċõďë:9}", s);
}
[TestMethod]
public void EscapedPropertyNamesTest()
{
var s = Json5.Stringify(new Json5Object { { "\\\b\f\n\r\t\v\0\x01", 1 } });
Assert.AreEqual(@"{'\\\b\f\n\r\t\v\0\x01':1}", s);
}
[TestMethod]
public void MultiplePropertiesTest()
{
var s = Json5.Stringify(new Json5Object { { "abc", 1 }, { "def", 2 } });
Assert.AreEqual("{abc:1,def:2}", s);
}
[TestMethod]
public void NestedObjectsTest()
{
var s = Json5.Stringify(new Json5Object { { "a", new Json5Object { { "b", 2 } } } });
Assert.AreEqual("{a:{b:2}}", s);
}
[TestMethod]
public void CircularObjectsTest()
{
var o = new Json5Object();
o["a"] = o;
//Json5.Stringify(o);
Assert.Fail("Not Implemented");
}
}
}