| 7 | ) |
| 8 | |
| 9 | func TestPluralize(t *testing.T) { |
| 10 | tests := []struct { |
| 11 | name string |
| 12 | num int |
| 13 | thing string |
| 14 | expected string |
| 15 | }{ |
| 16 | { |
| 17 | name: "zero, no plural", |
| 18 | num: 0, |
| 19 | thing: "sushi", |
| 20 | expected: "0 sushi", |
| 21 | }, |
| 22 | { |
| 23 | name: "one, no plural", |
| 24 | num: 1, |
| 25 | thing: "sushi", |
| 26 | expected: "1 sushi", |
| 27 | }, |
| 28 | { |
| 29 | name: "negative, no plural", |
| 30 | num: -10, |
| 31 | thing: "sushi", |
| 32 | expected: "-10 sushi", |
| 33 | }, |
| 34 | { |
| 35 | name: "positive, plural", |
| 36 | num: 10, |
| 37 | thing: "sushi", |
| 38 | expected: "10 sushis", |
| 39 | }, |
| 40 | } |
| 41 | |
| 42 | for _, tt := range tests { |
| 43 | t.Run(tt.name, func(t *testing.T) { |
| 44 | assert.Equal(t, tt.expected, Pluralize(tt.num, tt.thing)) |
| 45 | }) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | func TestContains(t *testing.T) { |
| 50 | tests := []struct { |