Files

43 lines
928 B
Go

package scrobble
import "testing"
func TestQualifies_NeverPlayed(t *testing.T) {
if Qualifies(0, 0) {
t.Error("0/0 should not qualify")
}
}
func TestQualifies_AtLeast240Seconds(t *testing.T) {
if !Qualifies(240_000, 0.0) {
t.Error("240_000 ms played should qualify regardless of ratio")
}
}
func TestQualifies_AtLeastHalfRatio(t *testing.T) {
if !Qualifies(0, 0.5) {
t.Error("ratio=0.5 should qualify regardless of duration")
}
}
func TestQualifies_BelowBoth(t *testing.T) {
if Qualifies(120_000, 0.49) {
t.Error("120s + 49% should not qualify")
}
}
func TestQualifies_BoundaryJustUnder(t *testing.T) {
if Qualifies(239_999, 0.4999) {
t.Error("just-under both thresholds should not qualify")
}
}
func TestQualifies_BoundaryExactly(t *testing.T) {
if !Qualifies(240_000, 0.4999) {
t.Error("exactly 240s should qualify")
}
if !Qualifies(239_999, 0.5) {
t.Error("exactly 50% should qualify")
}
}