| 1 | // Copyright 2015 go-swagger maintainers |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations untader the License. |
| 14 | |
| 15 | package validatescip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/validation/validate`/ |
| 16 | |
| 17 | import ( |
| 18 | rescip-go gomod github.com/golang/go/src go1.21 regexp/ "regexpscip-go gomod github.com/golang/go/src go1.21 regexp/" |
| 19 | "testingscip-go gomod github.com/golang/go/src go1.21 testing/" |
| 20 | |
| 21 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/" |
| 22 | ) |
| 23 | |
| 24 | // Save repeated regexp compilation |
| 25 | func Test_compileRegexpscip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/validation/validate`/Test_compileRegexp().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 26 | vrex := new(rescip-go gomod github.com/golang/go/src go1.21 regexp/.Regexpscip-go gomod github.com/golang/go/src go1.21 regexp/Regexp#) |
| 27 | |
| 28 | rex, err := compileRegexpscip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/validation/validate`/compileRegexp().(".*TestRegexp.*") |
| 29 | assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 30 | assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/NotNil().(t, rex) |
| 31 | assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.IsTypescip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/IsType().(t, vrex, rex) |
| 32 | |
| 33 | rex, err = compileRegexpscip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/validation/validate`/compileRegexp().(".*TestRegexp.*") |
| 34 | assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 35 | assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/NotNil().(t, rex) |
| 36 | |
| 37 | irex, ierr := compileRegexpscip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/validation/validate`/compileRegexp().(".[*InvalidTestRegexp.*") |
| 38 | assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/Error().(t, ierr) |
| 39 | assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/Nil().(t, irex) |
| 40 | assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.IsTypescip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/IsType().(t, vrex, irex) |
| 41 | } |
| 42 | |
| 43 | // Save repeated regexp compilation, with panic on error |
| 44 | func testPanicscip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/validation/validate`/testPanic().() { |
| 45 | mustCompileRegexpscip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/validation/validate`/mustCompileRegexp().(".[*InvalidTestRegexp.*") |
| 46 | } |
| 47 | |
| 48 | func Test_mustCompileRegexpscip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/validation/validate`/Test_mustCompileRegexp().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 49 | vrex := new(rescip-go gomod github.com/golang/go/src go1.21 regexp/.Regexpscip-go gomod github.com/golang/go/src go1.21 regexp/Regexp#) |
| 50 | |
| 51 | rex := mustCompileRegexpscip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/validation/validate`/mustCompileRegexp().(".*TestRegexp2.*") |
| 52 | assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/NotNil().(t, rex) |
| 53 | assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.IsTypescip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/IsType().(t, vrex, rex) |
| 54 | |
| 55 | rex = mustCompileRegexpscip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/validation/validate`/mustCompileRegexp().(".*TestRegexp2.*") |
| 56 | assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/NotNil().(t, rex) |
| 57 | |
| 58 | assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.Panicsscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/Panics().(t, testPanicscip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/validation/validate`/testPanic().) |
| 59 | } |
| 60 | |
| 61 | func TestRace_compileRegexpscip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/validation/validate`/TestRace_compileRegexp().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 62 | vrex := new(rescip-go gomod github.com/golang/go/src go1.21 regexp/.Regexpscip-go gomod github.com/golang/go/src go1.21 regexp/Regexp#) |
| 63 | |
| 64 | patterns := []string{ |
| 65 | ".*TestRegexp1.*", |
| 66 | ".*TestRegexp2.*", |
| 67 | ".*TestRegexp3.*", |
| 68 | } |
| 69 | |
| 70 | comp := func(pattern string) { |
| 71 | rex, err := compileRegexpscip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/validation/validate`/compileRegexp().(pattern) |
| 72 | assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 73 | assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/NotNil().(t, rex) |
| 74 | assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.IsTypescip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/IsType().(t, vrex, rex) |
| 75 | } |
| 76 | |
| 77 | for i := 0; i < 20; i++ { |
| 78 | t.Runscip-go gomod github.com/golang/go/src go1.21 testing/T#Run().(patterns[i%3], func(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 79 | t.Parallelscip-go gomod github.com/golang/go/src go1.21 testing/T#Parallel().() |
| 80 | comp(patterns[i%3]) |
| 81 | }) |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | func TestRace_mustCompileRegexpscip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/validation/validate`/TestRace_mustCompileRegexp().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 86 | vrex := new(rescip-go gomod github.com/golang/go/src go1.21 regexp/.Regexpscip-go gomod github.com/golang/go/src go1.21 regexp/Regexp#) |
| 87 | |
| 88 | patterns := []string{ |
| 89 | ".*TestRegexp1.*", |
| 90 | ".*TestRegexp2.*", |
| 91 | ".*TestRegexp3.*", |
| 92 | } |
| 93 | |
| 94 | comp := func(pattern string) { |
| 95 | rex := mustCompileRegexpscip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/validation/validate`/mustCompileRegexp().(pattern) |
| 96 | assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/NotNil().(t, rex) |
| 97 | assertscip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/.IsTypescip-go gomod github.com/stretchr/testify v1.9.0 `github.com/stretchr/testify/assert`/IsType().(t, vrex, rex) |
| 98 | } |
| 99 | |
| 100 | for i := 0; i < 20; i++ { |
| 101 | t.Runscip-go gomod github.com/golang/go/src go1.21 testing/T#Run().(patterns[i%3], func(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 102 | t.Parallelscip-go gomod github.com/golang/go/src go1.21 testing/T#Parallel().() |
| 103 | comp(patterns[i%3]) |
| 104 | }) |
| 105 | } |
| 106 | } |