From 816b8d975f0f72557714de506bfc866e6abb36f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Thu, 30 Dec 2021 20:50:29 +0800 Subject: [PATCH] update --- utils/gourl/gourl_test.go | 60 +++++++++++++++++++++++++++++++++++-- utils/gouuid/gouuid_test.go | 20 ++++++++++--- 2 files changed, 73 insertions(+), 7 deletions(-) diff --git a/utils/gourl/gourl_test.go b/utils/gourl/gourl_test.go index 33e3e331..632a83b5 100644 --- a/utils/gourl/gourl_test.go +++ b/utils/gourl/gourl_test.go @@ -1,14 +1,68 @@ package gourl import ( - "log" "testing" + "time" ) func TestLenCode(t *testing.T) { - log.Println(LenCode("https://www.dtapp.net")) + type args struct { + s string + } + tests := []struct { + name string + args args + want string + }{{ + name: "https://www.dtapp.net", + }, { + name: "https://www.dtapp.net", + }, { + name: "https://www.dtapp.net", + }} + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + start := time.Now() + t.Log(LenCode(tt.name)) + elapsed := time.Since(start) + t.Log("run time", elapsed) + }) + } +} + +func BenchmarkLenCode(b *testing.B) { + for n := 0; n < b.N; n++ { + LenCode("https://www.dtapp.net") + } } func TestDeCode(t *testing.T) { - log.Println(DeCode(LenCode("https://www.dtapp.net"))) + type args struct { + s string + } + tests := []struct { + name string + args args + want string + }{{ + name: "https%3A%2F%2Fwww.dtapp.net", + }, { + name: "https%3A%2F%2Fwww.dtapp.net", + }, { + name: "https%3A%2F%2Fwww.dtapp.net", + }} + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + start := time.Now() + t.Log(DeCode(tt.name)) + elapsed := time.Since(start) + t.Log("run time", elapsed) + }) + } +} + +func BenchmarkDeCode(b *testing.B) { + for n := 0; n < b.N; n++ { + DeCode("https%3A%2F%2Fwww.dtapp.net") + } } diff --git a/utils/gouuid/gouuid_test.go b/utils/gouuid/gouuid_test.go index 50cc2d98..36e39e17 100644 --- a/utils/gouuid/gouuid_test.go +++ b/utils/gouuid/gouuid_test.go @@ -1,11 +1,23 @@ -package gouuid_test +package gouuid import ( - "fmt" - "gopkg.in/dtapps/go-library.v3/utils/gouuid" "testing" ) func TestGetUuId(t *testing.T) { - fmt.Println(gouuid.GetUuId()) + tests := []struct { + name string + want string + }{{}, {}, {}} + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Log(GetUuId()) + }) + } +} + +func BenchmarkGetUuId(b *testing.B) { + for n := 0; n < b.N; n++ { + GetUuId() + } }