1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

test: remove t.Log()

This commit is contained in:
dudaodong
2023-04-26 14:59:45 +08:00
parent 581e338889
commit 4311b9ac66
14 changed files with 15 additions and 38 deletions

View File

@@ -200,7 +200,6 @@ func TestCountSort(t *testing.T) {
}
comparator := &peopleAgeComparator{}
sortedPeopleByAge := CountSort(peoples, comparator)
t.Log(sortedPeopleByAge)
expected := "[{d 8} {b 10} {c 17} {a 20} {e 28}]"
actual := fmt.Sprintf("%v", sortedPeopleByAge)

View File

@@ -181,7 +181,6 @@ func TestBridge(t *testing.T) {
index := 0
for val := range c.Bridge(ctx, genVals()) {
// t.Logf("%v ", val) //0 1 2 3 4 5 6 7 8 9
assert.Equal(index, val)
index++
}

View File

@@ -306,7 +306,6 @@ func TestDeepClone(t *testing.T) {
for i, item := range cases {
cloned := DeepClone(item)
t.Log(cloned)
if &cloned == &item {
t.Fatalf("[TestDeepClone case #%d failed]: equal pointer", i)
}

View File

@@ -64,7 +64,6 @@ func TestHashMap_KeysValues(t *testing.T) {
keys := hm.Keys()
values := hm.Values()
t.Log(keys, values)
assert.Equal(3, len(values))
assert.Equal(3, len(keys))

View File

@@ -40,7 +40,6 @@ func TestBSTree_PreOrderTraverse(t *testing.T) {
bstree.Insert(4)
acturl := bstree.PreOrderTraverse()
t.Log(acturl)
assert.Equal([]int{6, 5, 2, 4, 7}, acturl)
}
@@ -55,7 +54,6 @@ func TestBSTree_PostOrderTraverse(t *testing.T) {
bstree.Insert(4)
acturl := bstree.PostOrderTraverse()
t.Log(acturl)
assert.Equal([]int{5, 2, 4, 7, 6}, acturl)
}
@@ -70,7 +68,6 @@ func TestBSTree_InOrderTraverse(t *testing.T) {
bstree.Insert(4)
acturl := bstree.InOrderTraverse()
t.Log(acturl)
assert.Equal([]int{2, 4, 5, 6, 7}, acturl)
}
@@ -85,7 +82,6 @@ func TestBSTree_LevelOrderTraverse(t *testing.T) {
bstree.Insert(4)
acturl := bstree.LevelOrderTraverse()
t.Log(acturl)
assert.Equal([]int{6, 5, 7, 2, 4}, acturl)
}
@@ -102,14 +98,12 @@ func TestBSTree_Delete(t *testing.T) {
bstree.Delete(4)
acturl1 := bstree.InOrderTraverse()
t.Log(acturl1)
assert.Equal([]int{2, 5, 6, 7}, acturl1)
//todo
// bstree.DeletetNode(6, comparator)
// bstree.Print()
// acturl2 := bstree.InOrderTraverse()
// t.Log(acturl2)
// assert.Equal([]int{2, 5, 7}, acturl2)
}

View File

@@ -20,9 +20,8 @@ func TestToFormat(t *testing.T) {
assert := internal.NewAssert(t, "TestToFormat")
tm, err := NewFormat("2022-03-18 17:04:05")
assert.Equal("2022-03-18 17:04:05", tm.ToFormat())
assert.IsNil(err)
t.Log("ToFormat -> ", tm.ToFormat())
}
func TestToFormatForTpl(t *testing.T) {
@@ -32,9 +31,8 @@ func TestToFormatForTpl(t *testing.T) {
assert.IsNotNil(err)
tm, err := NewFormat("2022-03-18 17:04:05")
assert.Equal("2022/03/18 17:04:05", tm.ToFormatForTpl("2006/01/02 15:04:05"))
assert.IsNil(err)
t.Log("ToFormatForTpl -> ", tm.ToFormatForTpl("2006/01/02 15:04:05"))
}
func TestToIso8601(t *testing.T) {
@@ -44,7 +42,6 @@ func TestToIso8601(t *testing.T) {
assert.IsNotNil(err)
tm, err := NewISO8601("2006-01-02T15:04:05.999Z")
assert.Equal("2006-01-02T23:04:05+08:00", tm.ToIso8601())
assert.IsNil(err)
t.Log("ToIso8601 -> ", tm.ToIso8601())
}

View File

@@ -254,7 +254,7 @@ func ExampleMTime() {
fmt.Println(err)
// Output:
// 1682391110
// 1682478195
// <nil>
}

View File

@@ -107,7 +107,7 @@ func TestReadFileToString(t *testing.T) {
_, err := f.WriteString("hello world")
if err != nil {
t.Log(err)
t.Error(err)
}
content, _ := ReadFileToString(path)
@@ -127,7 +127,7 @@ func TestClearFile(t *testing.T) {
_, err := f.WriteString("hello world")
if err != nil {
t.Log(err)
t.Error(err)
}
err = ClearFile(path)
@@ -151,7 +151,7 @@ func TestReadFileByLine(t *testing.T) {
_, err := f.WriteString("hello\nworld")
if err != nil {
t.Log(err)
t.Error(err)
}
expected := []string{"hello", "world"}
@@ -198,9 +198,9 @@ func TestFileMode(t *testing.T) {
CreateFile(srcFile)
mode, err := FileMode(srcFile)
assert.IsNil(err)
t.Log(mode)
assert.IsNotNil(mode)
assert.IsNil(err)
os.Remove(srcFile)
}
@@ -269,7 +269,7 @@ func TestMTime(t *testing.T) {
mtime, err := MTime("./testdata/test.txt")
assert.IsNil(err)
assert.Equal(int64(1682391110), mtime)
assert.Equal(int64(1682478195), mtime)
}
func TestSha(t *testing.T) {
@@ -289,7 +289,6 @@ func TestReadCsvFile(t *testing.T) {
assert := internal.NewAssert(t, "TestReadCsvFile")
content, err := ReadCsvFile("./testdata/test.csv")
t.Log(content)
assert.IsNil(err)

View File

@@ -55,8 +55,6 @@ func TestPretty(t *testing.T) {
result, err := Pretty(v)
assert.IsNil(err)
t.Log("result -> ", result)
assert.Equal(expects[i], result)
}
}

View File

@@ -78,7 +78,6 @@ func TestAverage(t *testing.T) {
assert.Equal(Average(0, 0), 0)
assert.Equal(Average(1, 1), 1)
avg := Average(1.2, 1.4)
t.Log(avg)
assert.Equal(1.3, RoundToFloat(avg, 1))
}

View File

@@ -182,7 +182,7 @@ func TestHttpClient_Get(t *testing.T) {
var todo Todo
err = httpClient.DecodeResponse(resp, &todo)
if err != nil {
t.Log(err)
t.FailNow()
}
assert.Equal(1, todo.Id)

View File

@@ -103,7 +103,7 @@ func TestEncodeUrl(t *testing.T) {
urlAddr := "http://www.lancet.com?a=1&b=[2]"
encodedUrl, err := EncodeUrl(urlAddr)
if err != nil {
t.Log(err)
t.Fail()
}
expected := "http://www.lancet.com?a=1&b=%5B2%5D"

View File

@@ -57,7 +57,6 @@ func TestRandNumeralOrLetter(t *testing.T) {
reg := regexp.MustCompile(pattern)
randStr := RandNumeralOrLetter(10)
t.Log(randStr)
assert := internal.NewAssert(t, "TestRandNumeralOrLetter")
assert.Equal(10, len(randStr))
@@ -68,7 +67,6 @@ func TestRandInt(t *testing.T) {
assert := internal.NewAssert(t, "TestRandInt")
r1 := RandInt(1, 10)
t.Log(r1)
assert.GreaterOrEqual(r1, 1)
assert.Less(r1, 10)
@@ -99,7 +97,6 @@ func TestUUIdV4(t *testing.T) {
uuid, err := UUIdV4()
if err != nil {
t.Log(err)
t.Fail()
}

View File

@@ -594,7 +594,6 @@ func TestInsertAt(t *testing.T) {
assert.Equal([]string{"a", "b", "c", "1"}, InsertAt(strs, 3, "1"))
assert.Equal([]string{"1", "2", "3", "a", "b", "c"}, InsertAt(strs, 0, []string{"1", "2", "3"}))
assert.Equal([]string{"a", "b", "c", "1", "2", "3"}, InsertAt(strs, 3, []string{"1", "2", "3"}))
t.Log(strs)
}
func TestUpdateAt(t *testing.T) {
@@ -821,10 +820,9 @@ func TestSortBy(t *testing.T) {
return a.Age < b.Age
})
t.Logf("sort users by age: %v", users)
// output
// [{b 15} {a 21} {c 100}]
assert.EqualValues(15, users[0].Age)
assert.EqualValues(21, users[1].Age)
assert.EqualValues(100, users[2].Age)
}
func TestSortByFielDesc(t *testing.T) {
@@ -890,7 +888,6 @@ func TestShuffle(t *testing.T) {
s := []int{1, 2, 3, 4, 5}
res := Shuffle(s)
t.Log("Shuffle result: ", res)
assert.Equal(5, len(res))
}