Skip to content

Commit a689023

Browse files
committed
Implement text keyvalues 3
1 parent 4b1bb26 commit a689023

70 files changed

Lines changed: 3306 additions & 47 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ValveKeyValue/ValveKeyValue.Test/ApiSurfaceTestCase.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ public void ApiSurfaceIsWellKnown()
1313
var expected = TestDataHelper.ReadTextResource("apisurface.txt");
1414
var actual = GenerateApiSurface(typeof(KVObject).GetTypeInfo().Assembly);
1515

16+
if (expected != actual)
17+
{
18+
File.WriteAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, "apisurface.txt"), actual);
19+
}
20+
1621
Assert.That(actual, Is.EqualTo(expected), "This may indicate a breaking change.");
1722
}
1823

ValveKeyValue/ValveKeyValue.Test/KVBasicObjectIndexerTestCase.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ namespace ValveKeyValue.Test
33
class KVBasicObjectIndexerTestCase
44
{
55
[Test]
6-
public void IndexerOnValueNodeThrowsException()
6+
public void IndexerOnValueNodeReturnsNull()
77
{
8-
Assert.That(
9-
() => data["baz"],
10-
Throws.Exception.InstanceOf<InvalidOperationException>()
11-
.With.Message.EqualTo("This operation on a KVObject can only be used when the value has children."));
8+
Assert.That(data["baz"], Is.Null);
129
}
1310

1411
KVObject data;

ValveKeyValue/ValveKeyValue.Test/KVValueToStringTestCase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections;
2+
using System.Linq;
23

34
namespace ValveKeyValue.Test
45
{
@@ -13,7 +14,7 @@ public static IEnumerable ToStringTestCases
1314
{
1415
yield return new TestCaseData(new KVObject("a", "blah").Value).Returns("blah");
1516
yield return new TestCaseData(new KVObject("a", "yay").Value).Returns("yay");
16-
yield return new TestCaseData(new KVObject("a", []).Value).Returns("[Collection]").SetName("{m} - Empty Collection");
17+
yield return new TestCaseData(new KVObject("a", Enumerable.Empty<KVObject>()).Value).Returns("[Collection]").SetName("{m} - Empty Collection");
1718
yield return new TestCaseData(new KVObject("a", [new KVObject("boo", "aah")]).Value).Returns("[Collection]").SetName("{m} - Collection With Value");
1819
}
1920
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Keep intended line endings to test parser
2+
*.kv3 eol=lf
3+
*_crlf.kv3 eol=crlf
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
2+
{
3+
arrayValue =
4+
[
5+
"a",
6+
"b",
7+
]
8+
arrayOnSingleLine = [ 16.7551, 20.3763, 19.6448 ]
9+
arrayNoSpace=[1.3763,19.6448]
10+
arrayMixedTypes =
11+
[
12+
"a",
13+
1,
14+
true,
15+
false,
16+
null,
17+
{
18+
foo = "bar"
19+
},
20+
[
21+
1, 3, 3, 7
22+
],
23+
#[
24+
11 FF
25+
],
26+
resource:"hello.world",
27+
"""
28+
multiline
29+
string
30+
""",
31+
-69.420
32+
]
33+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
2+
{
3+
arrayValue = {
4+
"0" = "a"
5+
"1" = "b"
6+
}
7+
arrayOnSingleLine = {
8+
"0" = 16.755100
9+
"1" = 20.376300
10+
"2" = 19.644800
11+
}
12+
arrayNoSpace = {
13+
"0" = 1.376300
14+
"1" = 19.644800
15+
}
16+
arrayMixedTypes = {
17+
"0" = "a"
18+
"1" = 1
19+
"2" = 1
20+
"3" = 0
21+
"4" = ""
22+
"5" = {
23+
foo = "bar"
24+
}
25+
"6" = {
26+
"0" = 1
27+
"1" = 3
28+
"2" = 3
29+
"3" = 7
30+
}
31+
"7" = "11 FF"
32+
"8" = "hello.world"
33+
"9" = """
34+
multiline
35+
string
36+
"""
37+
"10" = -69.420000
38+
}
39+
test = "success"
40+
test = "success"
41+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
""
2+
{
3+
"arrayValue"
4+
{
5+
"0" "a"
6+
"1" "b"
7+
}
8+
"arrayOnSingleLine"
9+
{
10+
"0" "16.7551"
11+
"1" "20.3763"
12+
"2" "19.6448"
13+
}
14+
"arrayNoSpace"
15+
{
16+
"0" "1.3763"
17+
"1" "19.6448"
18+
}
19+
"arrayMixedTypes"
20+
{
21+
"0" "a"
22+
"1" "1"
23+
"2" "1"
24+
"3" "0"
25+
"4" ""
26+
"5"
27+
{
28+
"foo" "bar"
29+
}
30+
"6"
31+
{
32+
"0" "1"
33+
"1" "3"
34+
"2" "3"
35+
"3" "7"
36+
}
37+
"7" "11 FF"
38+
"8" "hello.world"
39+
"9" "multiline
40+
string"
41+
"10" "-69.42"
42+
}
43+
"test" "success"
44+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
2+
{
3+
array = [
4+
1,
5+
2,
6+
3,
7+
{
8+
array2 = [
9+
4,
10+
5,
11+
6,
12+
{
13+
something = "something"
14+
array3 = [
15+
7,
16+
8,
17+
9,
18+
]
19+
test = "abc"
20+
},
21+
10,
22+
]
23+
test2 = "def"
24+
},
25+
"string",
26+
11,
27+
12,
28+
[
29+
13,
30+
14,
31+
15,
32+
[
33+
16,
34+
17,
35+
18,
36+
],
37+
],
38+
19,
39+
]
40+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
2+
{
3+
arrayValue = [
4+
"a",
5+
"b",
6+
]
7+
arrayOnSingleLine = [
8+
16.755100,
9+
20.376300,
10+
19.644800,
11+
]
12+
arrayNoSpace = [
13+
1.376300,
14+
19.644800,
15+
]
16+
arrayMixedTypes = [
17+
"a",
18+
1,
19+
true,
20+
false,
21+
null,
22+
{
23+
foo = "bar"
24+
},
25+
[
26+
1,
27+
3,
28+
3,
29+
7,
30+
],
31+
#[
32+
11 FF
33+
],
34+
resource:"hello.world",
35+
"""
36+
multiline
37+
string
38+
""",
39+
-69.420000,
40+
]
41+
test = "success"
42+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
2+
{
3+
foo = "bar"
4+
}

0 commit comments

Comments
 (0)