package phraser

import "testing"

// The bug the helper exists for: the weather line said "градусов" for every
// reading, which is wrong for 1-4 and for every number ending in 1-4.
func TestDegreesAgreeWithTheReading(t *testing.T) {
	for temp, want := range map[float64]string{
		1: "градус", 1.4: "градус", 2: "градуса", 4: "градуса", 5: "градусов",
		0: "градусов", 11: "градусов", 14: "градусов", 21: "градус",
		22: "градуса", 25: "градусов", 101: "градус",
		// Minus does not change the noun, and a reading rounds to the number
		// she is about to say: -2.4° is "-2 градуса", not "-2 градусов".
		-1: "градус", -2.4: "градуса", -5: "градусов", -11: "градусов",
	} {
		if got := Degrees(temp); got != want {
			t.Errorf("Degrees(%v) = %q, want %q", temp, got, want)
		}
	}
}

func TestDevicesAgreeWithTheCount(t *testing.T) {
	for n, want := range map[int]string{
		1: "устройство", 2: "устройства", 4: "устройства", 5: "устройств",
		11: "устройств", 12: "устройств", 21: "устройство", 22: "устройства",
		25: "устройств", 111: "устройств", 101: "устройство", 0: "устройств",
	} {
		if got := Devices(n); got != want {
			t.Errorf("Devices(%d) = %q, want %q", n, got, want)
		}
	}
}
