(t *testing.T)
| 1010 | } |
| 1011 | |
| 1012 | func TestPredicateNamePositive(t *testing.T) { |
| 1013 | tests := []struct { |
| 1014 | name string |
| 1015 | str string |
| 1016 | want string |
| 1017 | }{ |
| 1018 | { |
| 1019 | name: "empty", |
| 1020 | str: "", |
| 1021 | want: "", |
| 1022 | }, |
| 1023 | { |
| 1024 | name: "single letter name", |
| 1025 | str: "x", |
| 1026 | want: "x", |
| 1027 | }, |
| 1028 | { |
| 1029 | name: "simple name", |
| 1030 | str: "xYz", |
| 1031 | want: "xYz", |
| 1032 | }, |
| 1033 | { |
| 1034 | name: "with parameters", |
| 1035 | str: "xYz(A,B,C)", |
| 1036 | want: "xYz", |
| 1037 | }, |
| 1038 | { |
| 1039 | name: "when does it end?", |
| 1040 | str: "foo(/bar", |
| 1041 | want: "foo", |
| 1042 | }, |
| 1043 | } |
| 1044 | for _, test := range tests { |
| 1045 | t.Run(test.name, func(t *testing.T) { |
| 1046 | got, err := PredicateName(test.str) |
| 1047 | if err != nil { |
| 1048 | t.Errorf("PredicateName(%v) failed with %v", test.str, err) |
| 1049 | } else if got != test.want { |
| 1050 | t.Errorf("PredicateName(%v) = %q want %v", test.str, got, test.want) |
| 1051 | } |
| 1052 | }) |
| 1053 | } |
| 1054 | } |
| 1055 | |
| 1056 | func TestPredicateNameNegative(t *testing.T) { |
| 1057 | tests := []struct { |
nothing calls this directly
no test coverage detected