stra_test.go 720 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package model
  2. import (
  3. "testing"
  4. . "github.com/smartystreets/goconvey/convey"
  5. )
  6. var stra = []Stra{
  7. Stra{Precision: 100, Ratio: []int{10, 90}},
  8. Stra{Precision: 100, Ratio: []int{10, 9}},
  9. }
  10. func TestCheck(t *testing.T) {
  11. Convey("TestCheck: ", t, func() {
  12. var checks = []bool{true, false}
  13. for i, s := range stra {
  14. got := s.Check()
  15. So(got, ShouldEqual, checks[i])
  16. }
  17. })
  18. }
  19. func TestVersion(t *testing.T) {
  20. testCase := map[int]int{9: 0, 20: 1}
  21. s := stra[0]
  22. Convey("TestVersion: ", t, func() {
  23. for j, k := range testCase {
  24. got, _ := s.Version(j)
  25. So(got, ShouldEqual, k)
  26. }
  27. _, err := s.Version(101)
  28. So(err, ShouldNotBeNil)
  29. _, err = stra[1].Version(101)
  30. So(err, ShouldNotBeNil)
  31. })
  32. }