Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
L-M-Sherlock committed Mar 14, 2024
1 parent 00449ed commit 0cb36bc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions fsrs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,18 @@ func TestMemoState(t *testing.T) {
t.Errorf("excepted:%v, got:%v", wantDifficulty, cardDifficulty)
}
}

func TestNextInterval(t *testing.T) {
p := DefaultParam()
p.W = Weights{1.0171, 1.8296, 4.4145, 10.9355, 5.0965, 1.3322, 1.017, 0.0, 1.6243, 0.1369, 1.0321,
2.1866, 0.0661, 0.336, 1.7766, 0.1693, 2.9244}
var ivlList []float64
for i := 1; i <= 10; i++ {
p.RequestRetention = float64(i) / 10
ivlList = append(ivlList, p.nextInterval(1))
}
wantIvlList := []float64{422, 102, 43, 22, 13, 8, 4, 2, 1, 1}
if !reflect.DeepEqual(ivlList, wantIvlList) {
t.Errorf("excepted:%v, got:%v", wantIvlList, ivlList)
}
}

0 comments on commit 0cb36bc

Please sign in to comment.