Beispiel #1
0
package gocheck_test

import (
	"errors"
	"github.com/jbenet/go-datastore/Godeps/_workspace/src/launchpad.net/gocheck"
	"reflect"
	"runtime"
)

type CheckersS struct{}

var _ = gocheck.Suite(&CheckersS{})

func testInfo(c *gocheck.C, checker gocheck.Checker, name string, paramNames []string) {
	info := checker.Info()
	if info.Name != name {
		c.Fatalf("Got name %s, expected %s", info.Name, name)
	}
	if !reflect.DeepEqual(info.Params, paramNames) {
		c.Fatalf("Got param names %#v, expected %#v", info.Params, paramNames)
	}
}

func testCheck(c *gocheck.C, checker gocheck.Checker, result bool, error string, params ...interface{}) ([]interface{}, []string) {
	info := checker.Info()
	if len(params) != len(info.Params) {
		c.Fatalf("unexpected param count in test; expected %d got %d", len(info.Params), len(params))
	}
	names := append([]string{}, info.Params...)
	result_, error_ := checker.Check(params, names)
	if result_ != result || error_ != error {
Beispiel #2
0
import (
	"fmt"
	"github.com/jbenet/go-datastore/Godeps/_workspace/src/launchpad.net/gocheck"
	"log"
	"os"
	"regexp"
	"strings"
)

// -----------------------------------------------------------------------
// Foundation test suite.

type FoundationS struct{}

var foundationS = gocheck.Suite(&FoundationS{})

func (s *FoundationS) TestCountSuite(c *gocheck.C) {
	suitesRun += 1
}

func (s *FoundationS) TestErrorf(c *gocheck.C) {
	// Do not use checkState() here.  It depends on Errorf() working.
	expectedLog := fmt.Sprintf("foundation_test.go:%d:\n"+
		"    c.Errorf(\"Error %%v!\", \"message\")\n"+
		"... Error: Error message!\n\n",
		getMyLine()+1)
	c.Errorf("Error %v!", "message")
	failed := c.Failed()
	c.Succeed()
	if log := c.GetTestLog(); log != expectedLog {
Beispiel #3
0
// somehow isn't working! :-)
//
// Do not assume *any* internal functionality works as expected besides
// what's actually tested here.

package gocheck_test

import (
	"fmt"
	"github.com/jbenet/go-datastore/Godeps/_workspace/src/launchpad.net/gocheck"
	"strings"
)

type BootstrapS struct{}

var boostrapS = gocheck.Suite(&BootstrapS{})

func (s *BootstrapS) TestCountSuite(c *gocheck.C) {
	suitesRun += 1
}

func (s *BootstrapS) TestFailedAndFail(c *gocheck.C) {
	if c.Failed() {
		critical("c.Failed() must be false first!")
	}
	c.Fail()
	if !c.Failed() {
		critical("c.Fail() didn't put the test in a failed state!")
	}
	c.Succeed()
}
Beispiel #4
0
// These tests verify the inner workings of the helper methods associated
// with gocheck.T.

package gocheck_test

import (
	"github.com/jbenet/go-datastore/Godeps/_workspace/src/launchpad.net/gocheck"
	"os"
	"reflect"
	"runtime"
	"sync"
)

var helpersS = gocheck.Suite(&HelpersS{})

type HelpersS struct{}

func (s *HelpersS) TestCountSuite(c *gocheck.C) {
	suitesRun += 1
}

// -----------------------------------------------------------------------
// Fake checker and bug info to verify the behavior of Assert() and Check().

type MyChecker struct {
	info   *gocheck.CheckerInfo
	params []interface{}
	names  []string
	result bool
	error  string
}