package main import ( "testing" "github.com/pkg/errors" "github.com/stretchr/testify/assert" ) func TestAlwaysTrue(t *testing.T) { assert.True(t, true) } func Test0ReturnsError(t *testing.T) { _, err := convertToRomanNumeral(0) assert.Error(t, err) } func Test1ReturnsI(t *testing.T) { AssertRoman(t, "I", 1) } func Test2ReturnsII(t *testing.T) { AssertRoman(t, "II", 2) } func Test3ReturnsIII(t *testing.T) { AssertRoman(t, "III", 3) } func AssertRoman(t *testing.T, expected string, what int) { numeral, _ := convertToRomanNumeral(what) assert.Equal(t, expected, numeral) } func convertToRomanNumeral(n int) (string, error) { var translate = map[int]string{ 1: "I", 2: "II", 3: "III", } if 0 == n { return "", errors.New("0 invalid") } return translate[n], nil }