1package sheet23import "testing"45func TestLogicFunctions(t *testing.T) {6 checkFormulas(t, fixture(t), []fnCase{7 {`=IFS(A1>20, "big", A1>5, "medium")`, txt("medium")},8 {`=IFS(A1>20, "big")`, ErrNA},9 {`=IFS(A4, 1)`, ErrValue},10 {`=SWITCH(B2, "north", 1, "south", 2)`, num(2)},11 {`=SWITCH(B4, "north", 1, "south", 2, 0)`, num(0)},12 {`=SWITCH(B4, "north", 1)`, ErrNA},13 {`=SWITCH(1, "1", "text", 1, "number")`, txt("number")},14 {"=XOR(TRUE, FALSE)", boolean(true)},15 {"=XOR(TRUE, TRUE)", boolean(false)},16 {"=XOR(A1:A3)", boolean(true)},17 {`=IFNA(NA(), "none")`, txt("none")},18 {"=IFNA(1/0, 0)", ErrDiv0},19 {"=ISBLANK(A5)", boolean(true)},20 {"=ISBLANK(B6)", boolean(false)}, // empty text isn't blank21 {"=ISNUMBER(A1)", boolean(true)},22 {"=ISNUMBER(A4)", boolean(false)},23 {"=ISNUMBER(F1)", boolean(true)}, // dates are numbers24 {"=ISTEXT(A4)", boolean(true)},25 {"=ISLOGICAL(A6)", boolean(true)},26 {"=ISERROR(1/0)", boolean(true)},27 {"=ISERROR(NA())", boolean(true)},28 {"=ISERR(NA())", boolean(false)},29 {"=ISNA(NA())", boolean(true)},30 {"=ISNA(1/0)", boolean(false)},31 })32}3334func TestStepArity(t *testing.T) {35 for _, in := range []string{`=SUMIFS(C1:C5, B1:B5)`, `=COUNTIFS(B1:B5, "a", C1:C5)`, `=IFS(TRUE, 1, FALSE)`} {36 if err := New().Set(at("A1"), in); err == nil {37 t.Errorf("Set(%q) accepted", in)38 }39 }40}