增加单元测试文件
This commit is contained in:
22
util/json_test.go
Normal file
22
util/json_test.go
Normal file
@ -0,0 +1,22 @@
|
||||
// Package util...
|
||||
//
|
||||
// Description : util...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2021-11-05 6:10 下午
|
||||
package util
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestJSONMarshal ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 6:12 下午 2021/11/5
|
||||
func TestJSONMarshal(t *testing.T) {
|
||||
data := `{"name":"zhangdeman", "age":18, "height": 180}`
|
||||
JSONConsoleOutput(data)
|
||||
}
|
60
util/url_test.go
Normal file
60
util/url_test.go
Normal file
@ -0,0 +1,60 @@
|
||||
// Package util...
|
||||
//
|
||||
// Description : util...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2021-11-04 2:58 下午
|
||||
package util
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestBuildQueryURL ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 3:04 下午 2021/11/4
|
||||
func TestBuildQueryURL(t *testing.T) {
|
||||
url := "https://ww.baidu.com/api/detail"
|
||||
parameter := map[string]string{
|
||||
"name": "zhang",
|
||||
"age": "18",
|
||||
}
|
||||
fmt.Println(BuildQueryURL(url, parameter))
|
||||
url = "https://ww.baidu.com/api/detail?tag=1"
|
||||
fmt.Println(BuildQueryURL(url, parameter))
|
||||
}
|
||||
|
||||
// TestURLDecode ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 3:04 下午 2021/11/4
|
||||
func TestURLDecode(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
// TestURLEncode ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 3:05 下午 2021/11/4
|
||||
func TestURLEncode(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
// TestURLParse 测试URL解析
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 3:00 下午 2021/11/4
|
||||
func TestURLParse(t *testing.T) {
|
||||
inputURL := "https://www.baidu.com/api/detail?a=1&b=2&a=3&d=qwe"
|
||||
r, _ := URLParse(inputURL)
|
||||
byteData, _ := json.Marshal(r)
|
||||
fmt.Println(string(byteData))
|
||||
}
|
Reference in New Issue
Block a user