MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / TestRotate

Function TestRotate

structure/linkedlist/cyclic_test.go:44–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestRotate(t *testing.T) {
45 type testCase struct {
46 param int
47 wantToReturn int
48 }
49 list := NewCyclic[int]()
50 fillList(list, 3)
51
52 testCases := []testCase{
53 {1, 2},
54 {3, 2},
55 {6, 2},
56 {7, 3},
57 {-2, 1},
58 {5, 3},
59 {8, 2},
60 {-8, 3},
61 }
62 for idx, tCase := range testCases {
63 list.Rotate(tCase.param)
64 got := list.Head.Val
65 if got != tCase.wantToReturn {
66 t.Errorf("got: %v, want: %v for test id %v", got, tCase.wantToReturn, idx)
67 }
68 }
69}
70
71func TestDelete(t *testing.T) {
72 list := NewCyclic[int]()

Callers

nothing calls this directly

Calls 2

fillListFunction · 0.85
RotateMethod · 0.80

Tested by

no test coverage detected