1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
| package util_test
import ( "testing"
"{{{ .Package }}}/app/util" )
//nolint:paralleltest func TestStringToPlural(t *testing.T) { tests := []struct { input string expected string }{ {"cat", "cats"}, {"dog", "dogs"}, {"child", "children"}, {"goose", "geese"}, {"man", "men"}, {"CLASS", "CLASSes"}, {"BUS", "BUSes"}, {"PASS", "PASSes"}, {"ox", "oxen"}, {"a", "as"}, }
for _, tt := range tests { x := tt result := util.StringToPlural(x.input) if result != x.expected { t.Errorf("StringToPlural(%s) = %s; expected %s", x.input, result, x.expected) } } }
//nolint:paralleltest func TestStringToSingular(t *testing.T) { tests := []struct { input string expected string }{ {"cats", "cat"}, {"dogs", "dog"}, {"children", "child"}, {"geese", "goose"}, {"men", "man"}, {"classes", "class"}, {"oxen", "ox"}, {"as", "a"}, }
for _, tt := range tests { x := tt result := util.StringToSingular(x.input) if result != x.expected { t.Errorf("StringToSingular(%s) = %s; expected %s", x.input, result, x.expected) } } }
//nolint:paralleltest func TestStringForms(t *testing.T) { tests := []struct { input string expectedSing string expectedPlural string }{ {"cat", "cat", "cats"}, {"dogs", "dog", "dogs"}, {"children", "child", "children"}, {"geese", "goose", "geese"}, {"CLASS", "CLASS", "CLASSes"}, }
for _, tt := range tests { x := tt singResult, pluralResult := util.StringForms(x.input) if singResult != x.expectedSing || pluralResult != x.expectedPlural { t.Errorf("StringForms(%s) = (%s, %s); expected (%s, %s)", x.input, singResult, pluralResult, x.expectedSing, x.expectedPlural) } } }
//nolint:paralleltest func TestStringPlural(t *testing.T) { tests := []struct { count int input string expected string }{ {1, "cat", "1 cat"}, {2, "dog", "2 dogs"}, {0, "child", "0 children"}, {-1, "goose", "-1 goose"}, {5, "man", "5 men"}, {3, "CLASS", "3 CLASSes"}, }
for _, tt := range tests { x := tt result := util.StringPlural(x.count, x.input) if result != x.expected { t.Errorf("StringPlural(%d, %s) = %s; expected %s", x.count, x.input, result, x.expected) } } }
|