-
Notifications
You must be signed in to change notification settings - Fork 0
/
php_test.go
209 lines (164 loc) · 4.36 KB
/
php_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
package php
import (
"net/url"
"testing"
)
func TestTime(t *testing.T) {
tt := Time()
t.Log(tt)
}
func TestDate(t *testing.T) {
tt := Time()
dd := Date("2006#01#02", tt)
t.Log(dd)
}
func TestStrtotime(t *testing.T) {
t.Log(Strtotime("hello world"))
t.Log(Strtotime("2019-07-22 23:23:23"))
}
func TestSleep(t *testing.T) {
t.Log(Time())
Sleep(5)
t.Log(Time())
}
func TestUSleep(t *testing.T) {
t.Log(Time())
Usleep(500000)
t.Log(Time())
}
//string ----
func TestStrlen(t *testing.T) {
t.Log(Strlen("hello world"))
t.Log(Strlen("您好世界!hello world"))
}
func TestMb_strlen(t *testing.T) {
t.Log(Mb_strlen("您好世界!hello world"))
}
func TestStr_replace(t *testing.T) {
t.Log(Str_replace("hello", "111", "hello world hello!", 1))
t.Log(Str_replace("hello", "111", "hello world hello!"))
}
func TestStrtolower(t *testing.T) {
t.Log(Strtolower("HELLO Wold!"))
}
func TestStrtoupper(t *testing.T) {
t.Log(Strtoupper("hello world!"))
}
func TestUcwords(t *testing.T) {
t.Log(Ucwords("hell world, how are you?"))
}
func TestSubstr(t *testing.T) {
t.Log(Substr("hello world!", 0, 2))
}
func TestStrrev(t *testing.T) {
t.Log(Strrev("hello world!啊a"))
}
func TestTrim(t *testing.T) {
t.Log(Trim(" 世界你好 " +
" \n "))
t.Log(Trim("世界\\r\\n\\t"))
}
func TestLTrim(t *testing.T) {
t.Log(Ltrim(" 世界你好 " +
" \n "))
t.Log(Ltrim(" aa aa 世界\\r\\n\\t"))
}
func TestRTrim(t *testing.T) {
t.Log(Rtrim(" 世界你好 " +
" \n "))
t.Log(Rtrim(" hello world 世界\r\\n\\t"))
}
func TestExplode(t *testing.T) {
t.Log(Explode(",", "a,b,c,d,e,f"))
}
func TestImplode(t *testing.T) {
t.Log(Implode(",", []string{"hello", "world", "!"}))
}
func TestChr(t *testing.T) {
t.Log(Chr(52))
t.Log(Chr(88))
t.Log(Chr(67))
}
func TestOrd(t *testing.T) {
t.Log(Ord("A"))
}
func TestMd5(t *testing.T) {
t.Log(Md5("123456"))
}
func TestMd5_file(t *testing.T) {
t.Log(Md5_file("php_test.go"))
}
func TestSha1(t *testing.T) {
t.Log(Sha1("123456"))
}
func TestSha1_file(t *testing.T) {
t.Log(Sha1_file("php_test.go"))
}
func TestBase64_encode(t *testing.T) {
t.Log(Base64_encode("啊啊嗯嗯版本哦哦"))
}
func TestBase64_decode(t *testing.T) {
en_str := Base64_encode("啊啊嗯嗯版本哦哦a e")
t.Log(en_str)
t.Log(Base64_decode(en_str))
}
func TestAddslashes(t *testing.T) {
t.Log(Addslashes("啊啊\"bbb'cccc"))
}
func TestHtmlentities(t *testing.T) {
t.Log(Htmlentities("<b>aaa</b>"))
}
func TestHTMLEntityDecode(t *testing.T) {
str := Htmlentities("<b>aaa</b>")
t.Log(Html_entity_decode(str))
}
func TestCrc32(t *testing.T) {
t.Log(Crc32("hello world"))
}
func TestUrl_encode(t *testing.T) {
t.Log(Url_encode("https://www.baidu.com/s?wd=php&rsv_spt=1&rsv_iqid=0x9c452cfc000a21bf&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&tn=baiduhome_pg&rsv_enter=1&rsv_sug3=4&rsv_sug1=4&rsv_sug7=101&rsv_sug2=0&inputT=1199&rsv_sug4=2130"))
}
func TestUrl_decode(t *testing.T) {
en_str := Url_encode("https://www.baidu.com/s?wd=php&rsv_spt=1&rsv_iqid=0x9c452cfc000a21bf&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&tn=baiduhome_pg&rsv_enter=1&rsv_sug3=4&rsv_sug1=4&rsv_sug7=101&rsv_sug2=0&inputT=1199&rsv_sug4=2130")
t.Log(en_str)
t.Log(Url_decode(en_str))
}
func TestHttp_build_query(t *testing.T) {
val := url.Values{}
val.Add("query", "baidu")
val.Add("page", "2")
t.Log(Http_build_query(val))
}
func TestUniqid(t *testing.T) {
t.Log(Uniqid())
t.Log(Uniqid("uid_"))
}
func TestFile_exists(t *testing.T) {
t.Log(File_exists("php.go"))
}
func TestIs_file(t *testing.T) {
t.Log(Is_file("php.go"))
t.Log(Is_file("/Users/wuzhijian"))
}
func TestIs_dir(t *testing.T) {
t.Log(Is_dir("php.go"))
t.Log(Is_dir("/Users/wuzhijian"))
}
func TestArray_keys(t *testing.T) {
arr := map[string]interface{}{"name": "wzj", "age": "33", "height": 170, "weight": 59.2}
t.Log(Array_keys(arr))
}
func TestArray_values(t *testing.T) {
arr := map[string]interface{}{"name": "wzj", "age": "33", "height": 170, "weight": 59}
t.Log(Array_values(arr))
}
func TestArray_column(t *testing.T) {
arr := []map[string]interface{}{
{"name": "wzj", "age": "33", "height": 170, "weight": 59.2},
{"name": "wzj", "age": "33", "height": 180, "weight": 59.2},
{"name": "wzj", "age": "33", "height": 190, "weight": 59.2},
{"name": "wzj", "age": "33", "heights": 200, "weight": 59.2},
{"name": "wzj", "age": "33", "height": 200, "weight": 59.2},
}
t.Log(Array_column(arr, "height"))
}