1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-03-01 00:35:28 +08:00

fix: fix TestEachWithBreak case

This commit is contained in:
dudaodong
2023-03-29 10:24:41 +08:00
parent da69b77892
commit e2522cd29b
2 changed files with 12 additions and 12 deletions

View File

@@ -175,7 +175,7 @@ func (s Set[T]) Minus(comparedSet Set[T]) Set[T] {
// EachWithBreak iterates over elements of a set and invokes function for each element, // EachWithBreak iterates over elements of a set and invokes function for each element,
// when iteratee return false, will break the for each loop. // when iteratee return false, will break the for each loop.
func (s Set[T]) EachWithBreak(iteratee func(item T) bool) { func (s Set[T]) EachWithBreak(iteratee func(item T) bool) {
for v := range s { for _, v := range s.Values() {
if !iteratee(v) { if !iteratee(v) {
break break
} }

View File

@@ -194,20 +194,20 @@ func TestSet_Minus(t *testing.T) {
} }
func TestEachWithBreak(t *testing.T) { func TestEachWithBreak(t *testing.T) {
// s := NewSet(1, 2, 3, 4, 5) s := NewSet(1, 2, 3, 4, 5)
// var sum int var sum int
// s.EachWithBreak(func(n int) bool { s.EachWithBreak(func(n int) bool {
// if n > 3 { if n > 3 {
// return false return false
// } }
// sum += n sum += n
// return true return true
// }) })
// assert := internal.NewAssert(t, "TestEachWithBreak") assert := internal.NewAssert(t, "TestEachWithBreak")
// assert.Equal(6, sum) assert.Equal(6, sum)
} }
// func TestPop(t *testing.T) { // func TestPop(t *testing.T) {