- NOTICE: copyright, GPL-3.0-only, and three additional terms of the kinds section 7 permits - (b) preserve the notices and the attribution in the program's legal notices, (c) mark a modified version as different and do not call it "FrameLedger" alone, (e) no trademark rights in the name. Shipped as licenses\NOTICE.txt; release.yml refuses a published tree without it. - Section 7 wants additional terms named in the source files: every first-party .cs .cpp .h .inl .ps1 .xaml file (1,053; src/native/third_party excluded) opens with the SPDX line and a pointer to NOTICE. tools/notice-check.ps1 is the gate (six self-test cases, both directions; -Fix writes a missing header) and tools/resx-gen.ps1 generates the string accessors with the header. - The native VERSIONINFO LegalCopyright said GPL-3.0-or-later; it now names the real licence. - CONTRIBUTING.md, FORKING.md, CODE_OF_CONDUCT.md (Contributor Covenant 2.1 by reference), legal/TRADEMARKS.md. - 12_BUILD gate list, CLAUDE.md layout and conventions. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
72 lines
2.8 KiB
C#
72 lines
2.8 KiB
C#
// SPDX-License-Identifier: GPL-3.0-only
|
|
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
|
|
|
using FluentAssertions;
|
|
using FrameLedger.Infrastructure.Import;
|
|
|
|
namespace FrameLedger.Infrastructure.Tests.Import;
|
|
|
|
/// <summary>Valve's KeyValues text (P4 PR-4): the two Steam files' shapes, comments, escapes, case-insensitive keys, and malformed input that costs an answer rather than throwing.</summary>
|
|
public sealed class ValveKeyValuesTests
|
|
{
|
|
[Fact]
|
|
public void AnAppManifestReadsBackItsFields()
|
|
{
|
|
const string acf = """
|
|
"AppState"
|
|
{
|
|
"appid" "1091500"
|
|
"name" "Cyberpunk 2077"
|
|
"installdir" "Cyberpunk 2077"
|
|
"buildid" "15877371" // a comment after the value
|
|
"UserConfig"
|
|
{
|
|
"language" "english"
|
|
}
|
|
}
|
|
""";
|
|
KeyValuesBlock root = ValveKeyValues.Parse(acf);
|
|
KeyValuesBlock state = root.Child("appstate")!;
|
|
state.Should().NotBeNull("keys compare case-insensitively");
|
|
state.Value("appid").Should().Be("1091500");
|
|
state.Value("name").Should().Be("Cyberpunk 2077");
|
|
state.Value("installdir").Should().Be("Cyberpunk 2077");
|
|
state.Value("buildid").Should().Be("15877371");
|
|
state.Child("UserConfig")!.Value("language").Should().Be("english");
|
|
}
|
|
|
|
[Fact]
|
|
public void LibraryFoldersListsEveryPathAndEscapesAreHonoured()
|
|
{
|
|
const string vdf = """
|
|
"libraryfolders"
|
|
{
|
|
"0"
|
|
{
|
|
"path" "C:\\Program Files (x86)\\Steam"
|
|
"apps" { "228980" "1234" }
|
|
}
|
|
"1"
|
|
{
|
|
"path" "D:\\SteamLibrary"
|
|
"label" "say \"hi\""
|
|
}
|
|
}
|
|
""";
|
|
KeyValuesBlock folders = ValveKeyValues.Parse(vdf).Child("libraryfolders")!;
|
|
folders.Children.Select(static c => c.Value.Value("path")).Should().Equal(@"C:\Program Files (x86)\Steam", @"D:\SteamLibrary");
|
|
folders.Child("1")!.Value("label").Should().Be("say \"hi\"");
|
|
folders.Child("0")!.Child("apps")!.Value("228980").Should().Be("1234", "bare and quoted tokens both parse");
|
|
}
|
|
|
|
[Fact]
|
|
public void MalformedInputCostsAnAnswerNotAnException()
|
|
{
|
|
ValveKeyValues.Parse("\"AppState\" { \"appid\" \"1\" ").Child("AppState")!.Value("appid").Should().Be("1", "an unterminated block keeps what parsed");
|
|
ValveKeyValues.Parse("\"key\"").Value("key").Should().BeNull("a key with no value is dropped");
|
|
ValveKeyValues.Parse("}}}{{{").Entries.Should().BeEmpty();
|
|
ValveKeyValues.Parse(string.Empty).Entries.Should().BeEmpty();
|
|
ValveKeyValues.Parse("\"unterminated").Entries.Should().BeEmpty();
|
|
}
|
|
}
|