github.com/googleapis/api-linter@v1.65.2/rules/internal/utils/string_pluralize_test.go (about) 1 // Copyright 2019 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package utils 16 17 import ( 18 "testing" 19 ) 20 21 func TestPluralize(t *testing.T) { 22 tests := []struct { 23 name string 24 word string 25 pluralizedWord string 26 }{ 27 {"PluralizeSingularWord", "person", "people"}, 28 {"PluralizePluralWord", "people", "people"}, 29 {"PluralizeNonstandardPluralWord", "persons", "people"}, 30 {"PluralizeNoPluralFormWord", "moose", "moose"}, 31 {"PluralizePluralLatinWord", "cacti", "cacti"}, 32 {"PluralizeNonstandardPluralLatinWord", "cactuses", "cacti"}, 33 {"PluralizePluralCamelCaseWord", "student_profiles", "student_profiles"}, 34 {"PluralizeSingularCamelCaseWord", "student_profile", "student_profiles"}, 35 } 36 for _, test := range tests { 37 t.Run(test.word, func(t *testing.T) { 38 if got := ToPlural(test.word); got != test.pluralizedWord { 39 t.Errorf("Plural(%s) got %s, but want %s", test.word, got, test.pluralizedWord) 40 } 41 }) 42 } 43 }