Relax case sensitive string comparisons in various parts of GCT

This commit is contained in:
Adrian Gallagher
2019-04-23 14:22:00 +10:00
parent 32e4dcb63d
commit 9bdcc22ae1
8 changed files with 29 additions and 32 deletions

View File

@@ -206,20 +206,20 @@ func StringDataCompare(haystack []string, needle string) bool {
return false
}
// StringDataCompareUpper data checks the substring array with an input and returns
// StringDataCompareInsensitive data checks the substring array with an input and returns
// a bool irrespective of lower or upper case strings
func StringDataCompareUpper(haystack []string, needle string) bool {
func StringDataCompareInsensitive(haystack []string, needle string) bool {
for x := range haystack {
if StringToUpper(haystack[x]) == StringToUpper(needle) {
if strings.EqualFold(haystack[x], needle) {
return true
}
}
return false
}
// StringDataContainsUpper checks the substring array with an input and returns
// StringDataContainsInsensitive checks the substring array with an input and returns
// a bool irrespective of lower or upper case strings
func StringDataContainsUpper(haystack []string, needle string) bool {
func StringDataContainsInsensitive(haystack []string, needle string) bool {
for _, data := range haystack {
if strings.Contains(StringToUpper(data), StringToUpper(needle)) {
return true

View File

@@ -338,13 +338,13 @@ func TestStringDataCompareUpper(t *testing.T) {
anotherNeedle := "WoRldD"
expectedOutput := true
expectedOutputTwo := false
actualResult := StringDataCompareUpper(originalHaystack, originalNeedle)
actualResult := StringDataCompareInsensitive(originalHaystack, originalNeedle)
if actualResult != expectedOutput {
t.Errorf("Test failed. Expected '%v'. Actual '%v'",
expectedOutput, actualResult)
}
actualResult = StringDataCompareUpper(originalHaystack, anotherNeedle)
actualResult = StringDataCompareInsensitive(originalHaystack, anotherNeedle)
if actualResult != expectedOutputTwo {
t.Errorf("Test failed. Expected '%v'. Actual '%v'",
expectedOutput, actualResult)
@@ -358,12 +358,12 @@ func TestStringDataContainsUpper(t *testing.T) {
anotherNeedle := "ning"
expectedOutput := true
expectedOutputTwo := false
actualResult := StringDataContainsUpper(originalHaystack, originalNeedle)
actualResult := StringDataContainsInsensitive(originalHaystack, originalNeedle)
if actualResult != expectedOutput {
t.Errorf("Test failed. Expected '%v'. Actual '%v'",
expectedOutput, actualResult)
}
actualResult = StringDataContainsUpper(originalHaystack, anotherNeedle)
actualResult = StringDataContainsInsensitive(originalHaystack, anotherNeedle)
if actualResult != expectedOutputTwo {
t.Errorf("Test failed. Expected '%v'. Actual '%v'",
expectedOutput, actualResult)