mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
Relax case sensitive string comparisons in various parts of GCT
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user