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 adbc5e1 commit 24b6582
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions slice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,39 @@ func TestAppend(t *testing.T) {
t.Fatalf("len(*Slice) != 2")
}
}

// TestAppendLength tests Slice.AppendLength.
func TestAppendLength(t *testing.T) {
s := &slice.Slice[int]{}
if n := s.AppendLength(1, 2, 3, 4); n != len(*s) {
t.Fatalf("len(*Slice) != 4")
}
}

// TestBounds tests Slice.Bounds.
func TestBounds(t *testing.T) {
s := &slice.Slice[int]{}
if ok := s.Bounds(0); ok {
t.Fatalf("*Slice.Bounds() != false")
}
s.Append(1)
if ok := s.Bounds(0); !ok {
t.Fatalf("*Slice.Bounds() != true")
}
}

// TestConcatenate tests Slice.Concatenate.
func TestConcatenate(t *testing.T) {
s := &slice.Slice[int]{}
s.Append(1)
s.Concatenate(&slice.Slice[int]{2, 3})
if ok := (*s)[0] == 1; !ok {
t.Fatalf("*Slice[0] != 1")
}
if ok := (*s)[1] == 2; !ok {
t.Fatalf("*Slice[1] != 2")
}
if ok := (*s)[2] == 3; !ok {
t.Fatalf("*Slice[2] != 3")
}
}

0 comments on commit 24b6582

Please sign in to comment.