package kata_test import ( "testing" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "code.osinet.fr/fgm/codewars/kyu7/growth_of_a_population" ) var _ = Describe("NbYear", func() { It("fixed tests", func() { Expect(NbYear(1500, 5, 100, 5000)).To(Equal(15)) Expect(NbYear(1500000, 2.5, 10000, 2000000)).To(Equal(10)) Expect(NbYear(1500000, 0.25, 1000, 2000000)).To(Equal(94)) Expect(NbYear(1500000, 0.25, -1000, 2000000)).To(Equal(151)) }) }) func TestPopN(t *testing.T) { checks := []struct { year, p0 int percent float64 aug, expected int }{ {1, 1000, 2, 50, 1070}, {2, 1000, 2, 50, 1141}, {3, 1000, 2, 50, 1213}, } for _, check := range checks { actual := PopN(check.p0, check.percent, check.aug, check.year) if actual != check.expected { t.Errorf("P0 %d + %0.2f + %d at year %d. Expected %d, got %d", check.p0, check.percent, check.aug, check.year, check.expected, actual) } } }