package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)[ \t]*(CATCH_)?(TEMPLATE_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\([ \t\n]*\"[^\"]*\"[ \t\n]*(,[ \t\n]*\"[^\"]*\")?(,[ \t\n]*[^,\)]*)*\)+[ \t\n]*\{+[ \t]*(//[^\n]*[Tt][Ii][Mm][Ee][Oo][Uu][Tt][ \t]*[0-9]+)*`)
var str = `TEST_CASE ("test")
{
Hello world;
}
TEST_CASE ("test with spaces {} []")
{
Hello world;
}
TEST_CASE ("test ) ", "case")
{
Hello world;
}
TEST_CASE ("test () ")
{
Hello world;
}
TEST_CASE("all is good")
{
REQUIRE(true);
}
TEMPLATE_TEST_CASE("aa", "[]", int, double, foo) {
}
CATCH_TEMPLATE_TEST_CASE("foo", "[tag]", T1, T2) {
}
CATCH_TEST_CASE("bbb") {
}`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Golang, please visit: https://golang.org/pkg/regexp/