Last active
March 1, 2019 13:53
-
-
Save jewzaam/336d378939189dfcdb069403003015af to your computer and use it in GitHub Desktop.
dedicated-admin namespace regex test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ go run test.go | |
2019/03/01 08:51:34 PASS: test=openshift-nmalik, expected=true, matched=true | |
2019/03/01 08:51:34 FAIL: test=nmalik-openshift-test, expected=false, matched=true | |
2019/03/01 08:51:34 PASS: test=nmalik-test, expected=false, matched=false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"regexp" | |
"log" | |
) | |
func main() { | |
tests := [3]string{"openshift-nmalik", "nmalik-openshift-test", "nmalik-test"} | |
expect := [3]bool{true,false,false} | |
for i, test := range tests { | |
matched, _ := regexp.MatchString("openshift-.*", test) | |
if (matched && expect[i]) || (!matched && !expect[i]) { | |
log.Printf("PASS: test=%s, expected=%t, matched=%t", test, expect[i], matched) | |
} else { | |
log.Printf("FAIL: test=%s, expected=%t, matched=%t", test, expect[i], matched) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment