| 1 | // Copyright ©2011-2012 The bíogo Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package feat |
| 6 | |
| 7 | import ( |
| 8 | "testing" |
| 9 | |
| 10 | "gopkg.in/check.v1" |
| 11 | ) |
| 12 | |
| 13 | func Test(t *testing.T) { check.TestingT(t) } |
| 14 | |
| 15 | type S struct{} |
| 16 | |
| 17 | var _ = check.Suite(&S{}) |
| 18 | |
| 19 | type testPos []struct { |
| 20 | zb, ob int |
| 21 | } |
| 22 | |
| 23 | var T = testPos{ |
| 24 | {0, 1}, |
| 25 | {1, 0}, |
| 26 | {-1, -1}, |
| 27 | {1, 2}, |
| 28 | } |
| 29 | |
| 30 | // Tests |
| 31 | func (s *S) TestPosition(c *check.C) { |
| 32 | for _, t := range T { |
| 33 | if t.ob == 0 { |
| 34 | c.Check(func() { OneToZero(t.ob) }, check.Panics, "feat: 1-based index == 0") |
| 35 | } else { |
| 36 | c.Check(OneToZero(t.ob), check.Equals, t.zb) |
| 37 | c.Check(ZeroToOne(t.zb), check.Equals, t.ob) |
| 38 | } |
| 39 | } |
| 40 | } |