1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-06 05:42:25 +08:00

fix: fix some go report issue

This commit is contained in:
dudaodong
2022-01-12 10:01:48 +08:00
4 changed files with 31 additions and 6 deletions

View File

@@ -6,7 +6,7 @@
<div align="center" style="text-align: center;">
![Go version](https://img.shields.io/badge/go-%3E%3D1.16<recommend>-9cf)
[![Release](https://img.shields.io/badge/release-1.1.8-green.svg)](https://github.com/duke-git/lancet/releases)
[![Release](https://img.shields.io/badge/release-1.1.9-green.svg)](https://github.com/duke-git/lancet/releases)
[![GoDoc](https://godoc.org/github.com//duke-git/lancet?status.svg)](https://pkg.go.dev/github.com/duke-git/lancet)
[![Go Report Card](https://goreportcard.com/badge/github.com/duke-git/lancet)](https://goreportcard.com/report/github.com/duke-git/lancet)
[![codecov](https://codecov.io/gh/duke-git/lancet/branch/main/graph/badge.svg?token=FC48T1F078)](https://codecov.io/gh/duke-git/lancet)

View File

@@ -6,7 +6,7 @@
<div align="center" style="text-align: center;">
![Go version](https://img.shields.io/badge/go-%3E%3D1.16<recommend>-9cf)
[![Release](https://img.shields.io/badge/release-1.1.8-green.svg)](https://github.com/duke-git/lancet/releases)
[![Release](https://img.shields.io/badge/release-1.1.9-green.svg)](https://github.com/duke-git/lancet/releases)
[![GoDoc](https://godoc.org/github.com//duke-git/lancet?status.svg)](https://pkg.go.dev/github.com/duke-git/lancet)
[![Go Report Card](https://goreportcard.com/badge/github.com/duke-git/lancet)](https://goreportcard.com/report/github.com/duke-git/lancet)
[![codecov](https://codecov.io/gh/duke-git/lancet/branch/main/graph/badge.svg?token=FC48T1F078)](https://codecov.io/gh/duke-git/lancet)

View File

@@ -18,7 +18,7 @@ const (
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 {
T *testing.T
CaseName string
@@ -154,9 +154,8 @@ func compare(x, y interface{}) int {
default:
if reflect.DeepEqual(x, y) {
return compareEqual
} else {
return compareNotEqual
}
return compareNotEqual
}
return compareNotEqual

View File

@@ -381,7 +381,7 @@ func TestDifference(t *testing.T) {
assert.Equal([]int{1, 2, 3}, Difference(s1, s2))
}
func TestSortByField(t *testing.T) {
func TestSortByFielDesc(t *testing.T) {
assert := internal.NewAssert(t, "TestWithout")
type student struct {
@@ -407,6 +407,32 @@ func TestSortByField(t *testing.T) {
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) {
assert := internal.NewAssert(t, "TestWithout")
assert.Equal([]int{3, 4, 5}, Without([]int{1, 2, 3, 4, 5}, 1, 2))