chore: optimize coding style and add unit tests (#3917)

This commit is contained in:
Kevin Wan
2024-02-17 15:50:07 +08:00
committed by GitHub
parent 28cb2c5804
commit 6be37ad533
2 changed files with 15 additions and 0 deletions

View File

@@ -15,3 +15,17 @@ func TestCalcEntropy(t *testing.T) {
}
assert.True(t, CalcEntropy(m) > .99)
}
func TestCalcEmptyEntropy(t *testing.T) {
m := make(map[any]int)
assert.Equal(t, float64(1), CalcEntropy(m))
}
func TestCalcDiffEntropy(t *testing.T) {
const total = 1000
m := make(map[any]int, total)
for i := 0; i < total; i++ {
m[i] = i
}
assert.True(t, CalcEntropy(m) < .99)
}