| 42 | } |
| 43 | |
| 44 | func 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 | |
| 71 | func TestDelete(t *testing.T) { |
| 72 | list := NewCyclic[int]() |