|
| 1 | +// Copyright 2026 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 aip0190 |
| 16 | + |
| 17 | +import "testing" |
| 18 | + |
| 19 | +func TestIsValidCamelCase(t *testing.T) { |
| 20 | + tests := []struct { |
| 21 | + name string |
| 22 | + input string |
| 23 | + want bool |
| 24 | + }{ |
| 25 | + {"ValidNormal", "CustomerId", true}, |
| 26 | + {"ValidXmlHttpRequest", "XmlHttpRequest", true}, |
| 27 | + {"ValidIpv6OnIosOptions", "Ipv6OnIosOptions", true}, |
| 28 | + {"ValidABTestingService", "ABTestingService", true}, |
| 29 | + {"ValidHttpABTestingService", "HttpABTestingService", true}, |
| 30 | + // Multiple allowlist entries with trailing lowercase letters. |
| 31 | + {"ValidABTestETaggingRequest", "ABTestETaggingRequest", true}, |
| 32 | + // Single letter words can also appear at the end of an allowlisted term. |
| 33 | + {"ValidPlanB", "ExecutePlanB", true}, |
| 34 | + // We sometimes require leading and trailing context for single letters . |
| 35 | + {"ValidTypeIIError", "TypeIIErrorResponse", true}, |
| 36 | + {"ValidXRay", "XRay", true}, |
| 37 | + {"ValidOAuth", "OAuth", true}, |
| 38 | + {"ValidABTest", "ABTest", true}, |
| 39 | + {"InvalidTShirtService", "TShirtService", false}, |
| 40 | + {"InvalidSnakeCase", "snake_case", false}, |
| 41 | + {"InvalidLowerCamelCase", "lowerCamelCase", false}, |
| 42 | + {"InvalidLowercase", "lowercase", false}, |
| 43 | + {"InvalidCustomerID", "CustomerID", false}, |
| 44 | + {"InvalidXMLHTTPRequest", "XMLHTTPRequest", false}, |
| 45 | + {"InvalidIPv6OnIOSOptions", "IPv6OnIOSOptions", false}, |
| 46 | + {"InvalidHTTPABTestingService", "HTTPABTestingService", false}, |
| 47 | + {"InvalidEMail", "EMail", false}, |
| 48 | + {"InvalidEBook", "EBook", false}, |
| 49 | + {"InvalidECommerce", "ECommerce", false}, |
| 50 | + } |
| 51 | + |
| 52 | + for _, test := range tests { |
| 53 | + t.Run(test.name, func(t *testing.T) { |
| 54 | + got := isValidCamelCase(test.input) |
| 55 | + if got != test.want { |
| 56 | + t.Errorf("isValidCamelCase(%q) = %t; want %t", test.input, got, test.want) |
| 57 | + } |
| 58 | + }) |
| 59 | + } |
| 60 | +} |
0 commit comments