func TestMakeButtonList(t *testing.T) {
  stringAssertTests := []StringAssert{
    StringAssert{
      actual: makeButtonList("One, Two, Three"),
      expected: "buttons {\"One\",\"Two\",\"Three\"}",
    },
    StringAssert{
      actual: makeButtonList("One"),
      expected: "buttons {\"One\"}",
    },
    StringAssert{
      actual: makeButtonList("One, Two, Three, Four"),
      expected: "buttons {\"One\",\"Two\",\"Three\"}",
    },
    StringAssert{
      actual: makeButtonList("One,Two"),
      expected: "buttons {\"One\",\"Two\"}",
    },
  }
  runStringAssertTests("makeButtonList", stringAssertTests, t)
}
Test parsing a button list
package mack
import (
  "errors"
  "strconv"
  "testing"
)
func TestRun(t *testing.T) {
  badAlert := AlertOptions{
    Buttons: "Yes, No, Don't Know",
    DefaultButton: "Non-existant-button",
  }
  badAlert2 := AlertOptions{
    Style: "none",
  }
  badDialog := DialogOptions{
    Icon: "invalid",
  }
  _, err1 := AlertBox(badAlert)
  _, err2 := AlertBox(badAlert2)
  _, err3 := DialogBox(badDialog)
  commands := []ErrorAssert{
    ErrorAssert{
      actual: Say("hi!", "non-existant-voice"),
      expected: errors.New("exit status 1: 0:36: execution error: Voice wasn’t found. (-244) " +
                           "(say \"hi!\" using \"non-existant-voice\")"),
    },
    ErrorAssert{
      actual: err1,
      expected: errors.New("exit status 1: 0:87: execution error: Specified button does not exist. (-50) " +
                           "(display alert \"\" buttons {\"Yes\",\"No\",\"Don't Know\"} default button \"Non-existant-button\")"),
    },
    ErrorAssert{
      actual: err2,
      expected: errors.New("exit status 1: 20:24: execution error: The variable none is not defined. (-2753) " +
                           "(display alert \"\" as none)"),
    },
    ErrorAssert{
      actual: err3,
      expected: errors.New("exit status 1: 28:35: execution error: The variable invalid is not defined. (-2753) " +
                           "(display dialog \"\" with icon invalid)"),
    },
  }
  validCommands := []ErrorAssert{
    ErrorAssert{actual: Say("hi!")},
    ErrorAssert{actual: Say("hi!", "Agnes")},
    ErrorAssert{actual: Beep(1)},
    ErrorAssert{actual: Beep(2)},
  }
  commands = append(commands, validCommands...)
  runErrorAssertTests("run", commands, t)
}
func TestWrapInQuotes(t *testing.T) {
  stringAssertTests := []StringAssert{
    StringAssert{
      actual: wrapInQuotes("Hello world!"),
      expected: "\"Hello world!\"",
    },
  }
  runStringAssertTests("wrapInQuotes", stringAssertTests, t)
}
func TestBuild(t *testing.T) {
  stringAssertTests := []StringAssert{
    StringAssert{
      actual: build("say","\"Hello world!\"", "using \"Agnes\""),
      expected: "say \"Hello world!\" using \"Agnes\"",
    },
  }
  runStringAssertTests("build", stringAssertTests, t)
}