当前位置: 首页>>代码示例>>Golang>>正文


Golang TB.Fail方法代码示例

本文整理汇总了Golang中testing.TB.Fail方法的典型用法代码示例。如果您正苦于以下问题:Golang TB.Fail方法的具体用法?Golang TB.Fail怎么用?Golang TB.Fail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在testing.TB的用法示例。


在下文中一共展示了TB.Fail方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ExpectNEQ

// ExpectNEQ fails the test and displays 'msg', if exp is equal to act.
func ExpectNEQ(tb testing.TB, exp, act interface{}, msg string) {
	if reflect.DeepEqual(exp, act) {
		_, file, line, _ := runtime.Caller(1)
		fmt.Printf("%s:%d: %s\n\n\texp: %#v\n\n\tgot: %#v\n\n", filepath.Base(file), line, msg, exp, act)
		tb.Fail()
	}
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:8,代码来源:helpers.go

示例2: Expect

// Expect fails the test and displays 'msg', if the condition is false.
func Expect(tb testing.TB, condition bool, msg string, v ...interface{}) {
	if !condition {
		_, file, line, _ := runtime.Caller(1)
		fmt.Printf("%s:%d: "+msg+"\n\n", append([]interface{}{filepath.Base(file), line}, v...)...)
		tb.Fail()
	}
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:8,代码来源:helpers.go

示例3: ExpectOk

// ExpectOk fails the test and displays 'err', if an err is not nil. Returns true if err is nil, false otherwise.
func ExpectOk(tb testing.TB, err error) bool {
	if err != nil {
		_, file, line, _ := runtime.Caller(1)
		fmt.Printf("%s:%d: unexpected error: %s\n\n", filepath.Base(file), line, err.Error())
		tb.Fail()
		return false
	}
	return true
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:10,代码来源:helpers.go

示例4: performChat

func performChat(t testing.TB, conn *grpc.ClientConn) error {
	serverClient := pb.NewPeerClient(conn)
	stream, err := serverClient.Chat(context.Background())
	if err != nil {
		t.Logf("%v.performChat(_) = _, %v", serverClient, err)
		return err
	}
	defer stream.CloseSend()
	t.Log("Starting performChat")

	waitc := make(chan struct{})
	go func() {
		// Be sure to close the channel
		defer close(waitc)
		for {
			in, err := stream.Recv()
			if err == io.EOF {
				t.Logf("Received EOR, exiting chat")
				return
			}
			if err != nil {
				t.Errorf("stream closed with unexpected error: %s", err)
				return
			}
			if in.Type == pb.Message_DISC_HELLO {
				t.Logf("Received message: %s, sending %s", in.Type, pb.Message_DISC_GET_PEERS)
				stream.Send(&pb.Message{Type: pb.Message_DISC_GET_PEERS})
			} else if in.Type == pb.Message_DISC_PEERS {
				//stream.Send(&pb.DiscoveryMessage{Type: pb.DiscoveryMessage_PEERS})
				t.Logf("Received message: %s", in.Type)
				t.Logf("Closing stream and channel")
				return
			} else {
				t.Logf("Received message: %s", in.Type)

			}

		}
	}()
	select {
	case <-waitc:
		return nil
	case <-time.After(1 * time.Second):
		t.Fail()
		return fmt.Errorf("Timeout expired while performChat")
	}
}
开发者ID:Colearo,项目名称:fabric,代码行数:47,代码来源:peer_test.go

示例5: sendLargeMsg

func sendLargeMsg(t testing.TB) (*pb.Message, error) {
	vm, err := container.NewVM()
	if err != nil {
		t.Fail()
		t.Logf("Error getting VM: %s", err)
		return nil, err
	}

	inputbuf, err := vm.GetPeerPackageBytes()
	if err != nil {
		t.Fail()
		t.Logf("Error Getting Peer package bytes: %s", err)
		return nil, err
	}
	payload, err := ioutil.ReadAll(inputbuf)
	return &pb.Message{Type: pb.Message_DISC_NEWMSG, Payload: payload}, nil

}
开发者ID:magooster,项目名称:obc-peer,代码行数:18,代码来源:peer_test.go

示例6: innerTest

func innerTest(client *FlumeClient, t testing.TB) {

	//header: {businessName=feed, type=list}.
	//body: 100311	list	{"view_self":0,"remoteid":"5445285","timestamp":1403512030,"flume_timestamp":"2014-06-23 16:27:10","business_type":"feed"}
	body := "{\"view_self\":0,\"remoteid\":\"5445285\",\"timestamp\":1403512030,\"flume_timestamp\":\"2014-06-23 16:27:10\",\"business_type\":\"feed\"}"

	var demo LogDemo
	err := json.Unmarshal([]byte(body), &demo)
	if nil != err {
		t.Fail()
		return
	}

	data, err := json.Marshal(demo)
	if nil != err {
		t.Fail()
		return
	}

	event := NewFlumeEvent("feed", "list", data)
	events := []*flume.ThriftFlumeEvent{event}
	for i := 0; i < 1; i++ {

		err := client.AppendBatch(events)
		err = client.Append(event)
		if nil != err {
			t.Log(err.Error())
			t.Fail()

		} else {
			t.Logf("%d, send succ ", i)
		}
	}
}
开发者ID:rejoicelee,项目名称:flume-log-sdk,代码行数:34,代码来源:flume_client_test.go

示例7: innerTest

func innerTest(client *FlumeClient, t testing.TB) {

	//header: {businessName=feed, type=list}.
	//body: 100311	list	{"view_self":0,"remoteid":"5445285","timestamp":1403512030,"flume_timestamp":"2014-06-23 16:27:10","business_type":"feed"}
	body := "{\"view_self\":0,\"remoteid\":\"5445285\",\"timestamp\":1403512030,\"flume_timestamp\":\"2014-06-23 16:27:10\",\"business_type\":\"feed\"}"

	var demo LogDemo
	err := json.Unmarshal([]byte(body), &demo)
	if nil != err {
		t.Fail()
		return
	}

	data, err := json.Marshal(demo)
	if nil != err {
		t.Fail()
		return
	}

	header := make(map[string]string, 2)
	header["businessName"] = "feed"
	header["type"] = "list"

	for i := 0; i < 1; i++ {

		err := client.Append(header, data)
		if nil != err {
			t.Log(err.Error())
			t.Fail()

		} else {
			t.Logf("%d, send succ ", i)
		}
	}
}
开发者ID:shijunbo,项目名称:flume-log-sdk,代码行数:35,代码来源:flume_client_test.go

示例8: assert

func (e *callRecord) assert(t testing.TB, name string, params ...interface{}) {
	if name != e.name {
		t.Logf("Expected call to %s%s", e.name, paramsToString(e.params))
		t.Logf(" got call to %s%s", name, paramsToString(params))
		showStack(t)
		t.Fail()
		return
	}
	if len(params) != len(e.params) {
		t.Logf("Call to (%s) unexpected parameters", name)
		t.Logf(" expected %s", paramsToString(e.params))
		t.Logf("      got %s", paramsToString(params))
		showStack(t)
		t.FailNow()
		return
	}
	for i, ap := range params {
		ep := e.params[i]

		if ap == nil && ep == nil {
			continue
		}

		switch ep := ep.(type) {
		case func(actual interface{}):
			ep(ap)
		default:
			if !reflect.DeepEqual(ap, ep) {
				t.Logf("Call to %s parameter %d unexpected", name, i)
				t.Logf("  expected %#v (%T)", ep, ep)
				t.Logf("       got %#v (%T)", ap, ap)
				showStack(t)
				t.Fail()
			}
		}
	}
}
开发者ID:patrickToca,项目名称:ut,代码行数:37,代码来源:callrecord.go

示例9: innerApsnHttpServerSend

func innerApsnHttpServerSend(t testing.TB) {

	// fmt.Println("innerApsnHttpServerSend is Starting")

	data := make(url.Values)
	data.Set("pt", NOTIFY_ENHANCED_FORMAT)
	data.Set("token", apnsToken)
	data.Set("sound", "ms.caf")
	data.Set("badge", "10")
	data.Set("body", "HTTP APNS SERVER TEST! ")
	data.Set("extArgs", "{\"name\":\"blackbeans\"}")

	//然后发起调用
	resp, err := http.PostForm(PROXY_URL+"/apns/push", data)
	if nil != err {
		t.Logf("HTTP POST PUSH FAIL!%s\n", err)
		t.Fail()
		return
	}

	var body []byte
	body, err = ioutil.ReadAll(resp.Body)
	if nil != err {
		// fmt.Printf("HTTP READ RESPONSE FAIL !|%s", err)
		t.Fail()
		return
	}

	defer resp.Body.Close()

	var response response
	err = json.Unmarshal(body, &response)
	if nil != err {
		// fmt.Printf("innerApsnHttpServerSend|HTTP Unmarshal RESPONSE FAIL !|%s\n", body)
		t.Fail()
		return
	}
	// fmt.Printf("--------------respose:%s\n", response)

	if response.Status != RESP_STATUS_SUCC {
		t.Fail()
		return
	}
}
开发者ID:peter158,项目名称:go-apns,代码行数:44,代码来源:apns_http_test.go

示例10: testF

func testF(tb testing.TB, msg string, res bool) {
	if !res {
		fmt.Printf("exp: %s\n", msg)
		tb.Fail()
	}
}
开发者ID:najeira,项目名称:sql,代码行数:6,代码来源:values_test.go


注:本文中的testing.TB.Fail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。