primes_in_numbers_suite_test.go 842 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package kata_test
  2. import (
  3. "fmt"
  4. "testing"
  5. . "github.com/onsi/ginkgo"
  6. . "github.com/onsi/gomega"
  7. kata "code.osinet.fr/fgm/codewars/kyu5/primes_in_numbers"
  8. )
  9. func TestPrimesInNumbers(t *testing.T) {
  10. RegisterFailHandler(Fail)
  11. RunSpecs(t, "PrimesInNumbers Suite")
  12. }
  13. func ZTestPrimes(t *testing.T) {
  14. type checkType struct {
  15. limit int
  16. expected []int
  17. }
  18. checks := [...]checkType{
  19. {0, []int{}},
  20. {1, []int{}},
  21. {2, []int{2}},
  22. {10, []int{2, 3, 5, 7}},
  23. }
  24. for _, check := range checks {
  25. t.Run(fmt.Sprintf("Limit %d", check.limit), func(t *testing.T) {
  26. t.Parallel()
  27. actual := kata.Primes(check.limit)
  28. if len(actual) != len(check.expected) {
  29. t.Log(actual)
  30. t.FailNow()
  31. }
  32. for i := 0; i < len(actual); i++ {
  33. if check.expected[i] != actual[i] {
  34. t.Log(actual)
  35. t.Fail()
  36. }
  37. }
  38. })
  39. }
  40. }