(t *testing.T)
| 12 | func (s nodeValueStringer) String() string { return string(s) } |
| 13 | |
| 14 | func TestNodeSetValue(t *testing.T) { |
| 15 | for _, test := range []struct { |
| 16 | name string |
| 17 | value any |
| 18 | want string |
| 19 | }{ |
| 20 | {"string", "after", "after"}, |
| 21 | {"number", 42, "42"}, |
| 22 | {"stringer", nodeValueStringer("formatted"), "formatted"}, |
| 23 | } { |
| 24 | t.Run(test.name, func(t *testing.T) { |
| 25 | node := Root("before").Child("child") |
| 26 | node.SetValue(test.value) |
| 27 | if got := node.GivenValue(); got != test.value { |
| 28 | t.Errorf("GivenValue() = %v, want %v", got, test.value) |
| 29 | } |
| 30 | if got := ansi.Strip(node.Value()); got != test.want { |
| 31 | t.Errorf("Value() = %q, want %q", got, test.want) |
| 32 | } |
| 33 | wantTree := test.want + "\n└── child" |
| 34 | if got := ansi.Strip(node.String()); got != wantTree { |
| 35 | t.Errorf("String() = %q, want %q", got, wantTree) |
| 36 | } |
| 37 | }) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | func TestTreeSetChildValue(t *testing.T) { |
| 42 | root := Root("root").Child("before") |
nothing calls this directly
no test coverage detected