21 lines
305 B
Go
21 lines
305 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"math"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestGKI(t *testing.T) {
|
||
|
r := Reading{
|
||
|
Glucose: 77,
|
||
|
Ketone: 1.1,
|
||
|
}
|
||
|
expected := (77.0 / 18) / 1.1
|
||
|
epsilon := 0.0001 // Tolerance level
|
||
|
gki, _ := r.GKI()
|
||
|
|
||
|
if math.Abs(gki-expected) > epsilon {
|
||
|
t.Errorf("expected %v, got %v", expected, gki)
|
||
|
}
|
||
|
}
|