Skip to content

Commit

Permalink
Update slice_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsaygelle authored Sep 13, 2023
1 parent 604270c commit c3d74ac
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions slice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,47 @@ func TestEach(t *testing.T) {
}
})
}

// TestEachBreak tests Slice.EachBreak.
func TestEachBreak(t *testing.T) {
s := &slice.Slice[int]{1, 2, 3, 4, 5}
count := 0
s.EachBreak(func(i int, value int) bool {
count = count + 1
return false
})
if ok := count == 1; !ok {
t.Fatalf("count != 1")
}
}

// TestEachReverse tests Slice.EachReverse.
func TestEachReverse(t *testing.T) {
s := &slice.Slice[int]{1, 2, 3, 4, 5}
s.EachReverse(func(i int, value int) {
if ok := (*s)[i] == value; !ok {
t.Fatalf("*Slice[%d] != %d", i, value)
}
})
}

// TestEachReverseBreak tests Slice.EachReverseBreak.
func TestEachReverseBreak(t *testing.T) {
s := &slice.Slice[int]{1, 2, 3, 4, 5}
s.EachReverseBreak(func(i int, value int) bool {
count = count + 1

Check failure on line 121 in slice_test.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: count

Check failure on line 121 in slice_test.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: count

Check failure on line 121 in slice_test.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: count
return false
})
if ok := count == 1; !ok {

Check failure on line 124 in slice_test.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: count

Check failure on line 124 in slice_test.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: count

Check failure on line 124 in slice_test.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: count
t.Fatalf("count != 1")
}
}

// TestFetch tests Slice.Fetch.
func TestFetch(t *testing.T) {
s := &slice.Slice[int]{1}
value := s.Fetch()

Check failure on line 132 in slice_test.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

not enough arguments in call to s.Fetch

Check failure on line 132 in slice_test.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

not enough arguments in call to s.Fetch

Check failure on line 132 in slice_test.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

not enough arguments in call to s.Fetch
if ok := value == (*s)[0]; !ok {
t.Fatalf("%d != %d", value, (*s)[0])
}
}

0 comments on commit c3d74ac

Please sign in to comment.