Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
bandl | 77cde0b2ef | |
bandl | 3709b6f8e5 |
|
@ -0,0 +1,17 @@
|
|||
package lru
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 保证所有函数和变量最小作用域
|
||||
|
||||
func Test(a int) (string, error) {
|
||||
// awd
|
||||
return strconv.Itoa(a), nil
|
||||
}
|
||||
|
||||
func Nows() string {
|
||||
return time.Now().Format("2006-01-02")
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package lru
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTest(t *testing.T) {
|
||||
ts , err := Test(2)
|
||||
require.NoError(t, err)
|
||||
require.Regexp(t, `\d`, ts)
|
||||
ts, err = Test(3)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "3", ts)
|
||||
|
||||
require.Regexp(t, `\d{4}-\d{2}-\d{2}`, Nows())
|
||||
|
||||
}
|
Loading…
Reference in New Issue