github.com/wxnacy/go-tools@v0.0.9/hash_test.go (about)

     1  package tools
     2  
     3  import (
     4  	"os"
     5  	"testing"
     6  )
     7  
     8  func TestMd5(t *testing.T) {
     9  	var res string
    10  	res = Md5("wxnacy")
    11  	if res != "1f806eb48b670c40af49a3f764ba086f" {
    12  		t.Errorf("%s is error", res)
    13  	}
    14  }
    15  
    16  func TestMd5File(t *testing.T) {
    17  	os.Chdir(cacheDir)
    18  	var res string
    19  	FileWriteWithInterface("TestMd5File", "wxnacy")
    20  	res, err := Md5File("TestMd5File")
    21  	if err != nil {
    22  		t.Error(err)
    23  	}
    24  	if res != "1f806eb48b670c40af49a3f764ba086f" {
    25  		t.Errorf("%s != 1f806eb48b670c40af49a3f764ba086f", res)
    26  	}
    27  	DirFilesRemove(cacheDir, "")
    28  }