mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-14 01:32:27 +08:00
fix: fix some go report issue
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
<div align="center" style="text-align: center;">
|
<div align="center" style="text-align: center;">
|
||||||
|
|
||||||

|

|
||||||
[](https://github.com/duke-git/lancet/releases)
|
[](https://github.com/duke-git/lancet/releases)
|
||||||
[](https://pkg.go.dev/github.com/duke-git/lancet)
|
[](https://pkg.go.dev/github.com/duke-git/lancet)
|
||||||
[](https://goreportcard.com/report/github.com/duke-git/lancet)
|
[](https://goreportcard.com/report/github.com/duke-git/lancet)
|
||||||
[](https://codecov.io/gh/duke-git/lancet)
|
[](https://codecov.io/gh/duke-git/lancet)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<div align="center" style="text-align: center;">
|
<div align="center" style="text-align: center;">
|
||||||
|
|
||||||

|

|
||||||
[](https://github.com/duke-git/lancet/releases)
|
[](https://github.com/duke-git/lancet/releases)
|
||||||
[](https://pkg.go.dev/github.com/duke-git/lancet)
|
[](https://pkg.go.dev/github.com/duke-git/lancet)
|
||||||
[](https://goreportcard.com/report/github.com/duke-git/lancet)
|
[](https://goreportcard.com/report/github.com/duke-git/lancet)
|
||||||
[](https://codecov.io/gh/duke-git/lancet)
|
[](https://codecov.io/gh/duke-git/lancet)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const (
|
|||||||
compareGreater
|
compareGreater
|
||||||
)
|
)
|
||||||
|
|
||||||
// Assert is a simple implementation of assertion, only for internal useage
|
// Assert is a simple implementation of assertion, only for internal usage
|
||||||
type Assert struct {
|
type Assert struct {
|
||||||
T *testing.T
|
T *testing.T
|
||||||
CaseName string
|
CaseName string
|
||||||
@@ -154,9 +154,8 @@ func compare(x, y interface{}) int {
|
|||||||
default:
|
default:
|
||||||
if reflect.DeepEqual(x, y) {
|
if reflect.DeepEqual(x, y) {
|
||||||
return compareEqual
|
return compareEqual
|
||||||
} else {
|
|
||||||
return compareNotEqual
|
|
||||||
}
|
}
|
||||||
|
return compareNotEqual
|
||||||
}
|
}
|
||||||
|
|
||||||
return compareNotEqual
|
return compareNotEqual
|
||||||
|
|||||||
@@ -381,7 +381,7 @@ func TestDifference(t *testing.T) {
|
|||||||
assert.Equal([]int{1, 2, 3}, Difference(s1, s2))
|
assert.Equal([]int{1, 2, 3}, Difference(s1, s2))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSortByField(t *testing.T) {
|
func TestSortByFielDesc(t *testing.T) {
|
||||||
assert := internal.NewAssert(t, "TestWithout")
|
assert := internal.NewAssert(t, "TestWithout")
|
||||||
|
|
||||||
type student struct {
|
type student struct {
|
||||||
@@ -407,6 +407,32 @@ func TestSortByField(t *testing.T) {
|
|||||||
assert.Equal(students, studentsOfSortByAge)
|
assert.Equal(students, studentsOfSortByAge)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSortByFieldAsc(t *testing.T) {
|
||||||
|
assert := internal.NewAssert(t, "TestSortByField")
|
||||||
|
|
||||||
|
type student struct {
|
||||||
|
name string
|
||||||
|
age int
|
||||||
|
}
|
||||||
|
students := []student{
|
||||||
|
{"a", 10},
|
||||||
|
{"b", 15},
|
||||||
|
{"c", 5},
|
||||||
|
{"d", 6},
|
||||||
|
}
|
||||||
|
studentsOfSortByAge := []student{
|
||||||
|
{"c", 5},
|
||||||
|
{"d", 6},
|
||||||
|
{"a", 10},
|
||||||
|
{"b", 15},
|
||||||
|
}
|
||||||
|
|
||||||
|
err := SortByField(students, "age")
|
||||||
|
assert.IsNil(err)
|
||||||
|
|
||||||
|
assert.Equal(students, studentsOfSortByAge)
|
||||||
|
}
|
||||||
|
|
||||||
func TestWithout(t *testing.T) {
|
func TestWithout(t *testing.T) {
|
||||||
assert := internal.NewAssert(t, "TestWithout")
|
assert := internal.NewAssert(t, "TestWithout")
|
||||||
assert.Equal([]int{3, 4, 5}, Without([]int{1, 2, 3, 4, 5}, 1, 2))
|
assert.Equal([]int{3, 4, 5}, Without([]int{1, 2, 3, 4, 5}, 1, 2))
|
||||||
|
|||||||
Reference in New Issue
Block a user