1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
package cursed import "testing" func TestUseState(t *testing.T) { val, setVal := UseState[string]("hi") if val() != "hi" { t.Errorf("wanted %q but got %q", "hi", val()) } setVal("goodbye") if val() != "goodbye" { t.Errorf("wanted %q but got %q", "goodbye", val()) } }