Beispiel #1
0
func (s *CheckersS) TestBug(c *gocheck.C) {
	bug := gocheck.Bug("a %d bc", 42)
	info := bug.GetBugInfo()
	if info != "a 42 bc" {
		c.Fatalf("Bug() returned %#v", info)
	}
}
Beispiel #2
0
func (s *EmbeddedS) TestMethod(c *gocheck.C) {
	// http://code.google.com/p/go/issues/detail?id=906
	c.Check(s.called, gocheck.Equals, false,
		gocheck.Bug("The bug described in issue 906 is "+
			"affecting the runner"))
	s.called = true
}
Beispiel #3
0
func (s *QS) TestQueueTestLists(c *gocheck.C) {
	test := []int{}
	testi := 0
	reset := func() {
		test = test[0:0]
		testi = 0
	}
	push := func(i int) {
		test = append(test, i)
	}
	pop := func() (i int) {
		if testi == len(test) {
			return -1
		}
		i = test[testi]
		testi++
		return
	}

	for _, list := range queueTestLists {
		reset()
		q := queue{}
		for _, n := range list {
			if n == -1 {
				c.Assert(q.Pop(), gocheck.Equals, pop(),
					gocheck.Bug("With list %#v", list))
			} else {
				q.Push(n)
				push(n)
			}
		}

		for n := pop(); n != -1; n = pop() {
			c.Assert(q.Pop(), gocheck.Equals, n,
				gocheck.Bug("With list %#v", list))
		}

		c.Assert(q.Pop(), gocheck.Equals, nil,
			gocheck.Bug("With list %#v", list))
	}
}
Beispiel #4
0
func runsingletest(name, st string, no int, ep, ef, ee int, c *gocheck.C) {
	parser := NewParser(strings.NewReader(st), name)
	suite, err := parser.ReadSuite()
	if err != nil {
		c.Fatalf("Cannot read suite %s: %s", name, err.String())
		return
	}
	if len(suite.Test) <= no {
		titles := ""
		for i := range suite.Test {
			titles += ": " + suite.Test[i].Title + " : "
		}
		c.Fatalf("Suite %s has only %d tests [%s]. %d required to run.", name, len(suite.Test), titles, no)
		return
	}

	suite.RunTest(no)
	p, f, e := suite.Test[no].Stat()

	// Stopp test if error mismatch
	if e != ee {
		printresults(&suite.Test[no])
		c.Fatalf("Wrong no of errors: expected %d, obtained %d.", ee, e)
	}

	if p != ep || f != ef {
		printresults(&suite.Test[no])
		printresults(&suite.Test[no])
	}

	if p+f != ep+ef {
		fmt.Printf("\nResult: %#v\n\n", suite.Test[no].Result)
		c.Fatalf("Wrong no of executed tests: expected %d (p:%d, f:%d), obtained %d (p:%d, f:%d).",
			ep+ef, ep, ef, p+f, p, f)
	}
	c.Check(p, gocheck.Equals, ep, gocheck.Bug("Wrong number of passed tests"))
	c.Check(f, gocheck.Equals, ef, gocheck.Bug("Wrong number of failed tests"))
}