github.com/masterhung0112/hk_server/v5@v5.0.0-20220302090640-ec71aef15e1c/utils/urlencode_test.go (about) 1 // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 // See LICENSE.txt for license information. 3 4 package utils 5 6 import ( 7 "testing" 8 9 "github.com/stretchr/testify/require" 10 ) 11 12 func TestUrlEncode(t *testing.T) { 13 14 toEncode := "testing 1 2 3" 15 encoded := URLEncode(toEncode) 16 17 require.Equal(t, encoded, "testing%201%202%203") 18 19 toEncode = "testing123" 20 encoded = URLEncode(toEncode) 21 22 require.Equal(t, encoded, "testing123") 23 24 toEncode = "testing$#~123" 25 encoded = URLEncode(toEncode) 26 27 require.Equal(t, encoded, "testing%24%23~123") 28 }