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