mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
increase coverage for crypto #66
This commit is contained in:
@ -22,10 +22,29 @@ var (
|
||||
result = "d175a1ff66aedde64344785f7f7a3df8"
|
||||
)
|
||||
|
||||
type user struct {
|
||||
name string
|
||||
password string
|
||||
age int
|
||||
}
|
||||
|
||||
func TestEncrypt(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
encryptString := gmd5.Encrypt(s)
|
||||
gtest.Assert(encryptString, result)
|
||||
|
||||
encrypt := gmd5.Encrypt(123456)
|
||||
gtest.AssertNE(encrypt,"")
|
||||
})
|
||||
|
||||
gtest.Case(t, func() {
|
||||
user := &user{
|
||||
name: "派大星",
|
||||
password: "123456",
|
||||
age: 23,
|
||||
}
|
||||
encrypt := gmd5.Encrypt(user)
|
||||
gtest.AssertNE(encrypt,"")
|
||||
})
|
||||
}
|
||||
|
||||
@ -46,5 +65,5 @@ func TestEncryptFile(t *testing.T) {
|
||||
encryptFile := gmd5.EncryptFile(path)
|
||||
gtest.AssertNE(encryptFile, "")
|
||||
})
|
||||
os.Remove(path)
|
||||
defer os.Remove(path)
|
||||
}
|
||||
|
||||
@ -32,6 +32,10 @@ func TestEncrypt(t *testing.T) {
|
||||
encrypt := gsha1.Encrypt(user)
|
||||
gtest.AssertNE(encrypt, "")
|
||||
})
|
||||
gtest.Case(t, func() {
|
||||
s := gsha1.Encrypt("pibigstar")
|
||||
gtest.AssertNE(s, "")
|
||||
})
|
||||
}
|
||||
|
||||
func TestEncryptString(t *testing.T) {
|
||||
@ -51,5 +55,5 @@ func TestEncryptFile(t *testing.T) {
|
||||
encryptFile := gsha1.EncryptFile(path)
|
||||
gtest.AssertNE(encryptFile, "")
|
||||
})
|
||||
os.Remove(path)
|
||||
defer os.Remove(path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user