MCPcopy
hub / github.com/TheAlgorithms/Go / TestJosephusProblem

Function TestJosephusProblem

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

Source from the content-addressed store, hash-verified

102}
103
104func TestJosephusProblem(t *testing.T) {
105 type testCase struct {
106 param int
107 wantToReturn int
108 listCount int
109 }
110
111 testCases := []testCase{
112 {5, 4, 8},
113 {3, 8, 8},
114 {8, 5, 8},
115 {8, 5, 8},
116 {2, 14, 14},
117 {13, 56, 58},
118 {7, 5, 5},
119 }
120
121 for _, tCase := range testCases {
122 list := NewCyclic[int]()
123 fillList(list, tCase.listCount)
124 got := JosephusProblem(list, tCase.param)
125 if got != tCase.wantToReturn {
126 t.Errorf("got: %v, want: %v", got, tCase.wantToReturn)
127 }
128 }
129}

Callers

nothing calls this directly

Calls 2

fillListFunction · 0.85
JosephusProblemFunction · 0.85

Tested by

no test coverage detected