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


Golang T.Failed方法代码示例

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


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

示例1: TestFailIfEqualToWithUnequalInts

func TestFailIfEqualToWithUnequalInts(t *testing.T) {
	t2 := new(testing.T)
	Fail(t2).If(intsAreEqual(6, 5))
	if t2.Failed() {
		t.Error()
	}
}
开发者ID:tychofreeman,项目名称:Linear,代码行数:7,代码来源:util_test.go

示例2: DumpEtcdOnFailure

func DumpEtcdOnFailure(t *testing.T) {
	if !t.Failed() {
		return
	}

	pc := make([]uintptr, 10)
	goruntime.Callers(2, pc)
	f := goruntime.FuncForPC(pc[0])
	last := strings.LastIndex(f.Name(), "Test")
	if last == -1 {
		last = 0
	}
	name := f.Name()[last:]

	client := NewEtcdClient()
	etcdResponse, err := client.RawGet("/", false, true)
	if err != nil {
		t.Logf("error dumping etcd: %v", err)
		return
	}

	if err := ioutil.WriteFile(GetBaseDir()+"/etcd-dump-"+name+".json", etcdResponse.Body, os.FileMode(0444)); err != nil {
		t.Logf("error dumping etcd: %v", err)
		return
	}
}
开发者ID:Xmagicer,项目名称:origin,代码行数:26,代码来源:etcd.go

示例3: TestOFB

func TestOFB(t *testing.T) {
	for _, tt := range ofbTests {
		test := tt.name

		c, err := aes.NewCipher(tt.key)
		if err != nil {
			t.Errorf("%s: NewCipher(%d bytes) = %s", test, len(tt.key), err)
			continue
		}

		for j := 0; j <= 5; j += 5 {
			plaintext := tt.in[0 : len(tt.in)-j]
			ofb := cipher.NewOFB(c, tt.iv)
			ciphertext := make([]byte, len(plaintext))
			ofb.XORKeyStream(ciphertext, plaintext)
			if !bytes.Equal(ciphertext, tt.out[:len(plaintext)]) {
				t.Errorf("%s/%d: encrypting\ninput % x\nhave % x\nwant % x", test, len(plaintext), plaintext, ciphertext, tt.out)
			}
		}

		for j := 0; j <= 5; j += 5 {
			ciphertext := tt.out[0 : len(tt.in)-j]
			ofb := cipher.NewOFB(c, tt.iv)
			plaintext := make([]byte, len(ciphertext))
			ofb.XORKeyStream(plaintext, ciphertext)
			if !bytes.Equal(plaintext, tt.in[:len(ciphertext)]) {
				t.Errorf("%s/%d: decrypting\nhave % x\nwant % x", test, len(ciphertext), plaintext, tt.in)
			}
		}

		if t.Failed() {
			break
		}
	}
}
开发者ID:2thetop,项目名称:go,代码行数:35,代码来源:ofb_test.go

示例4: TestMultipleAfter

func TestMultipleAfter(t *testing.T) {
	fakeTest := testing.T{}

	g := Goblin(&fakeTest)

	after := 0
	g.Describe("Numbers", func() {

		g.After(func() {
			after++
		})

		g.After(func() {
			after++
		})

		g.It("Should call all the registered after", func() {
			g.Assert(after).Equal(0)
		})
	})

	if fakeTest.Failed() && after != 2 {
		t.Fatal("Failed")
	}
}
开发者ID:lukaszb,项目名称:goblin,代码行数:25,代码来源:describe_test.go

示例5: TestMultipleBefore

func TestMultipleBefore(t *testing.T) {
	fakeTest := testing.T{}

	g := Goblin(&fakeTest)

	g.Describe("Numbers", func() {
		before := 0

		g.Before(func() {
			before++
		})

		g.Before(func() {
			before++
		})

		g.It("Should have called all the registered before", func() {
			g.Assert(before).Equal(2)
		})
	})

	if fakeTest.Failed() {
		t.Fatal("Failed")
	}
}
开发者ID:lukaszb,项目名称:goblin,代码行数:25,代码来源:describe_test.go

示例6: TestCTR_AES

func TestCTR_AES(t *testing.T) {
	for _, tt := range ctrAESTests {
		test := tt.name

		c, err := aes.NewCipher(tt.key)
		if err != nil {
			t.Errorf("%s: NewCipher(%d bytes) = %s", test, len(tt.key), err)
			continue
		}

		for j := 0; j <= 5; j += 5 {
			in := tt.in[0 : len(tt.in)-j]
			ctr := cipher.NewCTR(c, tt.iv)
			encrypted := make([]byte, len(in))
			ctr.XORKeyStream(encrypted, in)
			if out := tt.out[0:len(in)]; !bytes.Equal(out, encrypted) {
				t.Errorf("%s/%d: CTR\ninpt %x\nhave %x\nwant %x", test, len(in), in, encrypted, out)
			}
		}

		for j := 0; j <= 7; j += 7 {
			in := tt.out[0 : len(tt.out)-j]
			ctr := cipher.NewCTR(c, tt.iv)
			plain := make([]byte, len(in))
			ctr.XORKeyStream(plain, in)
			if out := tt.in[0:len(in)]; !bytes.Equal(out, plain) {
				t.Errorf("%s/%d: CTRReader\nhave %x\nwant %x", test, len(out), plain, out)
			}
		}

		if t.Failed() {
			break
		}
	}
}
开发者ID:Greentor,项目名称:go,代码行数:35,代码来源:ctr_aes_test.go

示例7: TestUnarchiveRepo

func TestUnarchiveRepo(t *testing.T) {
	temp, err := ioutil.TempDir("", "unarchive-repo-test")
	clonePath := "go/src/github.com/baz/foo.bar"
	cloned := filepath.Join(temp, clonePath)

	wd, _ := os.Getwd()
	file := fmt.Sprintf("%s/test_data/TestUnarchiveRepo/baz-foo.bar-v4.0.3-44-fasdfadsflkjlkjlkjlkjlkjlkjlj.tar.gz", wd)
	unpacked, err := unarchiveRepo(file, temp, clonePath, testBuildtimeout)

	if err != nil {
		t.Errorf("|%v|", err)
	}

	if unpacked != cloned {
		t.Errorf("Should have been %s was %s", cloned, unpacked)
	}

	files, err := ioutil.ReadDir(cloned)
	if err != nil {
		t.Errorf("|%v|", err)
	}

	if len(files) != 2 {
		t.Errorf("Directory %s had %v files.", cloned, len(files))
	}

	if !t.Failed() {
		//only remove output on success
		os.RemoveAll(temp)
	}

}
开发者ID:jhannah,项目名称:grim,代码行数:32,代码来源:github_archive_test.go

示例8: TestOneHostVlan_regress

func TestOneHostVlan_regress(t *testing.T) {
	defer func() {
		utils.ConfigCleanupCommon(t, testbed.GetNodes())
		utils.StopOnError(t.Failed())
	}()

	cfgFile := utils.GetCfgFile("one_host_vlan")
	jsonCfg, err := ioutil.ReadFile(cfgFile)
	if err != nil {
		t.Fatalf("failed to read config file %s \n", err)
	}
	utils.ConfigSetupCommon(t, string(jsonCfg), testbed.GetNodes())

	node1 := testbed.GetNodes()[0]

	utils.StartServer(t, node1, "myContainer1")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer1")
	}()

	ipAddress := utils.GetIPAddress(t, node1, "orange-myContainer1", u.EtcdNameStr)
	utils.StartClient(t, node1, "myContainer2", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer2")
	}()
}
开发者ID:balajisiva,项目名称:netplugin,代码行数:26,代码来源:regression_test.go

示例9: TestIntegrationInsert

func TestIntegrationInsert(t *testing.T) {
	db := setUpDatabase(t)
	defer tearDownDatabase(db, t)

	// Add new document
	doc := &Person{Name: "Peter", Height: 185, Alive: true}
	err := db.Insert(doc)
	if err != nil {
		t.Fatal("Inserted new document, error:", err)
	}
	if doc.ID == "" {
		t.Error("Inserted new document, should have ID set. Doc:", doc)
	}
	if doc.Rev == "" {
		t.Error("Inserted new document, should have Rev set. Doc:", doc)
	}

	if t.Failed() {
		t.FailNow()
	}

	// Edit existing
	oldID, oldRev := doc.ID, doc.Rev
	doc.Alive = false
	err = db.Insert(doc)
	if doc.Rev == oldRev {
		t.Error("Edited existing document, should have different rev. Doc:", doc)
	}
	if doc.ID != oldID {
		t.Error("Edited existing document, should have same id. Old:", oldID, "New:", doc.ID, doc)
	}
	if err != nil {
		t.Fatal("Edited existing document, error:", err)
	}
}
开发者ID:edwardoid,项目名称:couch,代码行数:35,代码来源:couch_test.go

示例10: TestRefuteNil

func TestRefuteNil(t *testing.T) {
	T := new(testing.T) // Stub
	Go(T).RefuteNil(1, "should refute nil on int")
	if T.Failed() {
		t.Error("RefuteNil should not have failed.")
	}

	T = new(testing.T) // Stub
	Go(T).RefuteNil("a", "should refute nil on string")
	if T.Failed() {
		t.Error("RefuteNil should not have failed.")
	}

	T = new(testing.T) // Stub
	arr := []string{"a", "b"}
	Go(T).RefuteNil(arr, "should refute nil on array")
	if T.Failed() {
		t.Error("RefuteNil should not have failed.")
	}

	T = new(testing.T) // Stub
	var iface interface{}
	iface = "a"
	Go(T).RefuteNil(iface, "should refute nil on interface")
	if T.Failed() {
		t.Error("RefuteNil should not have failed.")
	}

	T = new(testing.T) // Stub
	Go(T).RefuteNil(nil, "should refute nil on int")
	if !T.Failed() {
		t.Error("RefuteNil should have failed.")
	}
}
开发者ID:jmervine,项目名称:env,代码行数:34,代码来源:got_test.go

示例11: TestStorage_create

func TestStorage_create(t *testing.T) {
	_, err := NewStorage("tests.db", true)
	if err != nil {
		t.Failed()
	}

}
开发者ID:ObjectIsAdvantag,项目名称:answering-machine,代码行数:7,代码来源:storage_test.go

示例12: TestAssertDeepEqual

func TestAssertDeepEqual(t *testing.T) {
	T := new(testing.T) // Stub
	Go(T).AssertDeepEqual(1, 1, "should assert deep equal int")
	if T.Failed() {
		t.Error("AssertDeepEqual should not have failed.")
	}

	T = new(testing.T) // Stub
	Go(T).AssertDeepEqual(1.0, 1.0)
	if T.Failed() {
		t.Error("AssertDeepEqual should not have failed.")
	}

	T = new(testing.T) // Stub
	m1 := map[string]string{"a": "a"}
	m2 := map[string]string{"a": "a"}
	Go(T).AssertDeepEqual(m1, m2, "should assert deep equal map")
	if T.Failed() {
		t.Error("AssertDeepEqual should not have failed.")
	}

	T = new(testing.T) // Stub
	a1 := []string{"a", "b"}
	a2 := []string{"a", "b"}
	Go(T).AssertDeepEqual(a1, a2, "should assert deep equal array")
	if T.Failed() {
		t.Error("AssertDeepEqual should not have failed.")
	}

	T = new(testing.T) // Stub
	Go(T).AssertDeepEqual(1, 2, "should assert deep equal int")
	if !T.Failed() {
		t.Error("AssertDeepEqual should have failed.")
	}
}
开发者ID:jmervine,项目名称:env,代码行数:35,代码来源:got_test.go

示例13: TestNestedBeforeEach

func TestNestedBeforeEach(t *testing.T) {
	fakeTest := testing.T{}

	g := Goblin(&fakeTest)

	g.Describe("Numbers", func() {
		before := 0

		g.BeforeEach(func() {
			before++
		})

		g.Describe("Addition", func() {
			g.BeforeEach(func() {
				before++
			})

			g.It("Should have called all the registered beforeEach", func() {
				g.Assert(before).Equal(2)
			})

			g.It("Should have called all the registered beforeEach also for this one", func() {
				g.Assert(before).Equal(4)
			})
		})

	})

	if fakeTest.Failed() {
		t.Fatal("Failed")
	}
}
开发者ID:lukaszb,项目名称:goblin,代码行数:32,代码来源:it_test.go

示例14: main

func main() {

	// catch errors
	var tst testing.T
	defer func() {
		if mpi.Rank() == 0 {
			if err := recover(); err != nil {
				io.PfRed("ERROR: %v\n", err)
			}
			if tst.Failed() {
				io.PfRed("test failed\n")
			}
		}
		mpi.Stop(false)
	}()
	mpi.Start(false)

	// start global variables and log
	analysis := fem.NewFEM("data/bh16.sim", "", true, true, false, true, true, 0)

	// run simulation
	err := analysis.Run()
	if err != nil {
		tst.Error("Run failed\n")
		return
	}

	// check
	skipK := true
	tolK := 1e-12
	tolu := 1e-15
	tols := 1e-12
	fem.TestingCompareResultsU(&tst, "data/bh16.sim", "cmp/bh16.cmp", "", tolK, tolu, tols, skipK, true)
}
开发者ID:PaddySchmidt,项目名称:gofem,代码行数:34,代码来源:t_bh16_main.go

示例15: TestBlock

func TestBlock(t *testing.T) {
	if err := bakupIptables(); err != nil {
		t.Fatalf("Backup iptables error [%s]\n", err)
	}
	if err := restoreTp(RULETP, ACCEPT); err != nil {
		t.Fatalf("Restore iptables template error [%s]\n", err)
	}
	rules, err := FetchAll()
	if err != nil {
		t.Fatalf("Fetch all rules error [%s]\n", err)
	}
	for id, _ := range rules {
		Block(id)
	}
	if err := Update(); err != nil {
		t.Fatalf("Update rules error [%s]\n", err)
	}
	rules, err = FetchAll()
	if err != nil {
		t.Fatalf("Fetch all rules again error [%s]\n", err)
	}
	for id, rule := range rules {
		if rule.Status == ACCEPT {
			t.Errorf("Container [%s] is not blocked", id)
		}
	}
	restoreIptables(originalRule)
	if !t.Failed() {
		t.Log("Block Passed")
	}
	return
}
开发者ID:hayatoshimizuBSKYB,项目名称:vcap-services,代码行数:32,代码来源:iptablesrun_test.go


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