From c4e7487ba7b3c332f9b914d81ae7025093b23869 Mon Sep 17 00:00:00 2001 From: Philippe ALEXANDRE Date: Tue, 15 May 2018 11:48:49 +0200 Subject: [PATCH 1/2] Do case insensitive comparaison for booleans - Fix #125 --- check/test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/check/test.go b/check/test.go index eaf0a12..4e1507c 100644 --- a/check/test.go +++ b/check/test.go @@ -80,10 +80,20 @@ func (t *testItem) execute(s string) (result bool) { switch t.Compare.Op { case "eq": - result = flagVal == t.Compare.Value + // Do case insensitive comparaison for booleans ... + if value == "false" || value == "true" { + result = value == t.Compare.Value + } else { + result = flagVal == t.Compare.Value + } case "noteq": - result = !(flagVal == t.Compare.Value) + // Do case insensitive comparaison for booleans ... + if value == "false" || value == "true" { + result = !(value == t.Compare.Value) + } else { + result = !(flagVal == t.Compare.Value) + } case "gt": a, b := toNumeric(flagVal, t.Compare.Value) From 7b61cf60fe7c8946c581dcf3107efb902b001620 Mon Sep 17 00:00:00 2001 From: Philippe ALEXANDRE Date: Tue, 15 May 2018 11:52:49 +0200 Subject: [PATCH 2/2] Add strings.ToLower ... --- check/test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/check/test.go b/check/test.go index 4e1507c..2470721 100644 --- a/check/test.go +++ b/check/test.go @@ -80,6 +80,7 @@ func (t *testItem) execute(s string) (result bool) { switch t.Compare.Op { case "eq": + value := strings.ToLower(flagVal) // Do case insensitive comparaison for booleans ... if value == "false" || value == "true" { result = value == t.Compare.Value @@ -88,6 +89,7 @@ func (t *testItem) execute(s string) (result bool) { } case "noteq": + value := strings.ToLower(flagVal) // Do case insensitive comparaison for booleans ... if value == "false" || value == "true" { result = !(value == t.Compare.Value)