package builderkeys import "testing" // 1886/AC1: a builder that keeps no say, or a say without the word, is a builder that does not write references; one // instance that says it is enough, since it builds every key done without a reference again (ADR 0498 ยง8). func TestTheBuilderSaysReferencesOnlyWhenAnInstanceSaysTheWord(t *testing.T) { cases := []struct { name string values [][]byte want bool }{ {"no instance", nil, false}, {"an instance saying nothing", [][]byte{[]byte(`{"writes":[]}`)}, false}, {"a value not read", [][]byte{[]byte(`{not json`)}, false}, {"another word", [][]byte{[]byte(`{"writes":["digests"]}`)}, false}, {"one instance says it", [][]byte{[]byte(`{"writes":["digests"]}`), []byte(`{"v":1,"writes":["references"]}`)}, true}, } for _, c := range cases { if got := saysReferences(c.values); got != c.want { t.Errorf("%s: says references %v, want %v", c.name, got, c.want) } } }