v0.4.0 Unmapped reads any parsed value, UnknownKeys refuses what it names, decode errors name the key path
Test / test (push) Canceled after 0s

This commit is contained in:
Lixen authored and lixen committed 2026-10-26 03:33:39 -04:00
1 parent 170e71f10a
commit e5d5567beb
5 files changed
+80 -16

No files matched your search

+7
View File
@@ -195,6 +195,7 @@ func TestDocumentRefusesAnEditItCannotPlace(t *testing.T) {
// TestUnmappedNamesWhatDecodeIgnores: keys no field takes, by tag or field name,
// unexported and "-" fields included, are named once each, under arrays of tables
// without their index; a map or interface destination takes every key under it.
// A parsed tree is read as its document is, and UnknownKeys quotes each.
func TestUnmappedNamesWhatDecodeIgnores(t *testing.T) {
doc := `top = 1
skip = 2
@@ -248,6 +249,12 @@ nope = 1
if !slices.Equal(got, want) {
t.Fatalf("unmapped %q, want %q", got, want)
}
if tree := Unmapped(d.Tree(), &v); !slices.EqualFunc(tree, d.Unmapped(&v), slices.Equal) {
t.Fatalf("the tree's unmapped %q differ from the document's", tree)
}
if err := UnknownKeys(d.Unmapped(&v)[:2]).Error(); err != `unknown keys "byname.one.nope", "hidden"` {
t.Fatalf("error %s", err)
}
}
// TestKeyStringQuotesWhatABareKeyCannotHold