github.com/zhongdalu/gf@v1.0.0/g/text/gstr/gstr_z_unit_trim_test.go (about) 1 // Copyright 2019 gf Author(https://github.com/zhongdalu/gf). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/zhongdalu/gf. 6 7 // go test *.go -bench=".*" 8 9 package gstr_test 10 11 import ( 12 "github.com/zhongdalu/gf/g/test/gtest" 13 "github.com/zhongdalu/gf/g/text/gstr" 14 "testing" 15 ) 16 17 func Test_Trim(t *testing.T) { 18 gtest.Case(t, func() { 19 gtest.Assert(gstr.Trim(" 123456\n "), "123456") 20 gtest.Assert(gstr.Trim("#123456#;", "#;"), "123456") 21 }) 22 } 23 24 func Test_TrimRight(t *testing.T) { 25 gtest.Case(t, func() { 26 gtest.Assert(gstr.TrimRight(" 123456\n "), " 123456") 27 gtest.Assert(gstr.TrimRight("#123456#;", "#;"), "#123456") 28 }) 29 } 30 31 func Test_TrimRightStr(t *testing.T) { 32 gtest.Case(t, func() { 33 gtest.Assert(gstr.TrimRightStr("gogo我爱gogo", "go"), "gogo我爱") 34 }) 35 } 36 37 func Test_TrimLeft(t *testing.T) { 38 gtest.Case(t, func() { 39 gtest.Assert(gstr.TrimLeft(" \r123456\n "), "123456\n ") 40 gtest.Assert(gstr.TrimLeft("#;123456#;", "#;"), "123456#;") 41 }) 42 } 43 44 func Test_TrimLeftStr(t *testing.T) { 45 gtest.Case(t, func() { 46 gtest.Assert(gstr.TrimLeftStr("gogo我爱gogo", "go"), "我爱gogo") 47 }) 48 }