Skip to content

Commit cff9230

Browse files
committed
Add expected array serialization
1 parent df3cbc3 commit cff9230

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed
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.7551,
9+
20.3763,
10+
19.6448,
11+
]
12+
arrayNoSpace = [
13+
1.3763,
14+
19.6448,
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.42,
40+
]
41+
test = "success"
42+
}

ValveKeyValue/ValveKeyValue.Test/TextKV3/Kv3ToKv1TestCase.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ public void SerializesArraysToObjects()
5252
text = reader.ReadToEnd();
5353
}
5454

55-
System.Console.WriteLine(text);
56-
5755
Assert.That(text, Is.EqualTo(expected));
5856
}
5957
}

ValveKeyValue/ValveKeyValue.Test/TextKV3/SerializationTestCase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void CreatesTextDocument()
3333
public void SerializesArray()
3434
{
3535
using var stream = TestDataHelper.OpenResource("TextKV3.array.kv3");
36-
var expected = TestDataHelper.ReadTextResource("TextKV3.array.kv3");
36+
var expected = TestDataHelper.ReadTextResource("TextKV3.array_serialized.kv3");
3737

3838
var kv = KVSerializer.Create(KVSerializationFormat.KeyValues3Text);
3939
var data = kv.Deserialize(stream);

ValveKeyValue/ValveKeyValue/Serialization/KeyValues3/KV3TextSerializer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public void OnArrayEnd()
6464
indentation--;
6565
WriteIndentation();
6666
writer.Write(']');
67+
// TODO: Write comma if we're in an array
6768
writer.WriteLine();
6869
}
6970

@@ -94,6 +95,7 @@ void WriteEndObject()
9495
indentation--;
9596
WriteIndentation();
9697
writer.Write('}');
98+
// TODO: Write comma if we're in an array
9799
writer.WriteLine();
98100
}
99101

0 commit comments

Comments
 (0)