diff options
Diffstat (limited to 'factors/factors_test.go')
| -rw-r--r-- | factors/factors_test.go | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/factors/factors_test.go b/factors/factors_test.go index 33727c0..b7f48b9 100644 --- a/factors/factors_test.go +++ b/factors/factors_test.go @@ -3,7 +3,6 @@ package factors import ( "fmt" "maps" - "math" "testing" ) @@ -59,18 +58,14 @@ func TestFactors(t *testing.T) { } var totativeRatioCases = map[uint]float64{ - 1: 1.0, - 2: 0.5, - 3: 2.0 / 3.0, - 4: 0.5, - 6: 1.0 / 3.0, - 8: 0.5, - 12: 1.0 / 3.0, + 1: 1.0, 2: 0.5, 3: 2.0 / 3.0, 4: 0.5, + 6: 1.0 / 3.0, 7: 6.0 / 7.0, 8: 0.5, + 12: 1.0 / 3.0, 14: 3.0 / 7.0, 15: 8.0 / 15.0, + 30: 4.0 / 15.0, 60: 4.0 / 15.0, 120: 4.0 / 15.0, } func TestTotativeRatio(t *testing.T) { - equals := func(a, b float64) bool { return floatEquals(a, b, 1e-15) } - tableTest(t, TotativeRatio, totativeRatioCases, equals, "TotativeRatio") + tableTest(t, TotativeRatio, totativeRatioCases, stdEquals, "TotativeRatio") } var factorScoreCases = map[uint]float64{ @@ -199,7 +194,3 @@ func setEquals[E comparable](a, b []E) bool { } return maps.Equal(aSet, bSet) } - -func floatEquals(a, b, maxDelta float64) bool { - return math.Abs(a-b) <= maxDelta*math.Max(math.Abs(a), math.Abs(b)) -} |
