-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
populate string table dynamically + remove likely premature optimization
- Loading branch information
Showing
4 changed files
with
83 additions
and
37 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
ValveKeyValue/ValveKeyValue.Test/Binary/StringTableFromScratchTestCase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Linq; | ||
|
||
namespace ValveKeyValue.Test | ||
{ | ||
class StringTableFromScratchTestCase | ||
{ | ||
[Test] | ||
public void PopulatesStringTableDuringSerialization() | ||
{ | ||
var kv = new KVObject("root", | ||
[ | ||
new KVObject("key", "value"), | ||
new KVObject("child", [ | ||
new KVObject("key", 123), | ||
]), | ||
]); | ||
|
||
var stringTable = new StringTable(); | ||
|
||
var serializer = KVSerializer.Create(KVSerializationFormat.KeyValues1Binary); | ||
|
||
using var ms = new MemoryStream(); | ||
serializer.Serialize(ms, kv, new KVSerializerOptions { StringTable = stringTable }); | ||
|
||
var strings = stringTable.ToArray(); | ||
Assert.That(strings, Is.EqualTo(new[] { "root", "key", "child" })); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters