github.com/dubbogo/gost@v1.14.0/strings/strings_test.go (about) 1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package gxstrings 19 20 import ( 21 "testing" 22 ) 23 24 import ( 25 "github.com/stretchr/testify/assert" 26 ) 27 28 func Test_RegSplit(t *testing.T) { 29 strings := RegSplit("dubbo://123.1.2.1;jsonrpc://127.0.0.1;registry://3.2.1.3?registry=zookeeper", "\\s*[;]+\\s*") 30 assert.Len(t, strings, 3) 31 assert.Equal(t, "dubbo://123.1.2.1", strings[0]) 32 assert.Equal(t, "jsonrpc://127.0.0.1", strings[1]) 33 assert.Equal(t, "registry://3.2.1.3?registry=zookeeper", strings[2]) 34 } 35 36 func TestIsMatchPattern(t *testing.T) { 37 assert.Equal(t, true, IsMatchPattern("*", "value")) 38 assert.Equal(t, true, IsMatchPattern("", "")) 39 assert.Equal(t, false, IsMatchPattern("", "value")) 40 assert.Equal(t, true, IsMatchPattern("value", "value")) 41 assert.Equal(t, true, IsMatchPattern("v*", "value")) 42 assert.Equal(t, true, IsMatchPattern("*ue", "value")) 43 assert.Equal(t, true, IsMatchPattern("*e", "value")) 44 assert.Equal(t, true, IsMatchPattern("v*e", "value")) 45 assert.Equal(t, true, IsMatchPattern("val*e", "value")) 46 }