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


Golang C.Failed方法代码示例

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


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

示例1: TestFailedAndSucceed

func (s *BootstrapS) TestFailedAndSucceed(c *gocheck.C) {
	c.Fail()
	c.Succeed()
	if c.Failed() {
		critical("c.Succeed() didn't put the test back in a non-failed state")
	}
}
开发者ID:kelsieflynn,项目名称:gocheck,代码行数:7,代码来源:bootstrap_test.go

示例2: TestRetire

func (s *S) TestRetire(c *gocheck.C) {
	defer func() {
		if r := recover(); !c.Failed() && r == nil {
			c.Errorf("Should panic in ping, but did not!")
		}
	}()
	Open("127.0.0.1:27017", "tsuru_storage_test")
	sess := conn["127.0.0.1:27017"]
	sess.used = sess.used.Add(-1 * 2 * period)
	conn["127.0.0.1:27017"] = sess
	var ticker time.Ticker
	ch := make(chan time.Time, 1)
	ticker.C = ch
	ch <- time.Now()
	var wg sync.WaitGroup
	wg.Add(1)
	go func() {
		retire(&ticker)
		wg.Done()
	}()
	close(ch)
	wg.Wait()
	_, ok := conn["127.0.0.1:27017"]
	c.Check(ok, gocheck.Equals, false)
	sess.s.Ping()
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:26,代码来源:storage_test.go

示例3: TestReadGFF

func (s *S) TestReadGFF(c *check.C) {
	obtain := []*feat.Feature{}
	if r, err := NewReaderName(G[0]); err != nil {
		c.Fatalf("Failed to open %q: %s", G[0], err)
	} else {
		for i := 0; i < 3; i++ {
			for {
				if f, err := r.Read(); err != nil {
					if err == io.EOF {
						break
					} else {
						c.Fatalf("Failed to read %q: %s", G[0], err)
					}
				} else {
					obtain = append(obtain, f)
				}
			}
			if c.Failed() {
				break
			}
			if len(obtain) == len(expect) {
				for j := range obtain {
					c.Check(*obtain[j], check.DeepEquals, expect[j])
				}
			} else {
				c.Check(len(obtain), check.Equals, len(expect))
			}
		}
		c.Check(r.Type, check.Equals, bio.Moltype(0))
		r.Close()
	}
}
开发者ID:frogs,项目名称:biogo,代码行数:32,代码来源:gff_test.go

示例4: TestColor

func (s *S) TestColor(c *check.C) {
	for r := 0; r < 256; r += 5 {
		for g := 0; g < 256; g += 5 {
			for b := 0; b < 256; b += 5 {
				col := color.RGBA{uint8(r), uint8(g), uint8(b), 0}
				cDirectR, cDirectG, cDirectB, cDirectA := col.RGBA()
				hsva := RGBAtoHSVA(col.RGBA())
				c.Check(hsva.H, floatWithinRange, float64(0), float64(360))
				c.Check(hsva.S, floatWithinRange, float64(0), float64(1))
				c.Check(hsva.V, floatWithinRange, float64(0), float64(1))
				cFromHSVR, cFromHSVG, cFromHSVB, cFromHSVA := hsva.RGBA()
				c.Check(cFromHSVR, uintWithinRange, uint32(0), uint32(0xFFFF))
				c.Check(cFromHSVG, uintWithinRange, uint32(0), uint32(0xFFFF))
				c.Check(cFromHSVB, uintWithinRange, uint32(0), uint32(0xFFFF))
				back := RGBAtoHSVA(color.RGBA{uint8(cFromHSVR >> 8), uint8(cFromHSVG >> 8), uint8(cFromHSVB >> 8), uint8(cFromHSVA)}.RGBA())
				c.Check(hsva, check.Equals, back)
				c.Check(cFromHSVR, withinEpsilon, cDirectR, e)
				c.Check(cFromHSVG, withinEpsilon, cDirectG, e)
				c.Check(cFromHSVB, withinEpsilon, cDirectB, e)
				c.Check(cFromHSVA, check.Equals, cDirectA)
				if c.Failed() {
					return
				}
			}
		}
	}
}
开发者ID:frogs,项目名称:biogo,代码行数:27,代码来源:color_test.go

示例5: TestFailedAndFail

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()
}
开发者ID:kelsieflynn,项目名称:gocheck,代码行数:10,代码来源:bootstrap_test.go

示例6: TestCollectionClose

func (s *S) TestCollectionClose(c *gocheck.C) {
	defer func() {
		if r := recover(); !c.Failed() && r == nil {
			c.Errorf("Should panic in ping, but did not!")
		}
	}()
	storage, _ := Open("127.0.0.1:27017", "tsuru_storage_test")
	coll := Collection{storage.Collection("something").Collection}
	coll.Close()
	storage.session.Ping()
}
开发者ID:nightshade427,项目名称:tsuru,代码行数:11,代码来源:storage_test.go

示例7: TestSucceedNow

func (s *FoundationS) TestSucceedNow(c *gocheck.C) {
	defer (func() {
		if c.Failed() {
			c.Error("SucceedNow() didn't succeed the test")
		}
		if c.GetTestLog() != "" {
			c.Error("Something got logged:\n" + c.GetTestLog())
		}
	})()

	c.Fail()
	c.SucceedNow()
	c.Log("SucceedNow() didn't stop the test")
}
开发者ID:evaluation-alex,项目名称:gosync,代码行数:14,代码来源:foundation_test.go

示例8: TestErrorf

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 {
		c.Logf("Errorf() logged %#v rather than %#v", log, expectedLog)
		c.Fail()
	}
	if !failed {
		c.Logf("Errorf() didn't put the test in a failed state")
		c.Fail()
	}
}
开发者ID:evaluation-alex,项目名称:gosync,代码行数:18,代码来源:foundation_test.go

示例9: checkTarContents

func (s *LegacySuite) checkTarContents(
	c *gc.C, tarFile io.Reader, allExpected []tarContent,
) {
	contents := readTarFile(c, tarFile)

	// Check that the expected entries are there.
	// XXX Check for unexpected entries.
	for _, expected := range allExpected {
		relPath := strings.TrimPrefix(expected.Name, string(os.PathSeparator))

		c.Log(fmt.Sprintf("checking for presence of %q on tar file", relPath))
		body, found := contents[relPath]
		if !found {
			c.Errorf("%q not found", expected.Name)
			continue
		}

		if expected.Body != "" {
			c.Log("Also checking the file contents")
			c.Check(body, gc.Equals, expected.Body)
		}

		if expected.Nested != nil {
			c.Log("Also checking the nested tar file")
			nestedFile := bytes.NewBufferString(body)
			s.checkTarContents(c, nestedFile, expected.Nested)
		}
	}

	if c.Failed() {
		c.Log("-----------------------")
		c.Log("expected:")
		for _, expected := range allExpected {
			c.Log(fmt.Sprintf("%s -> %q", expected.Name, expected.Body))
		}
		c.Log("got:")
		for name, body := range contents {
			if len(body) > 200 {
				body = body[:200] + "...(truncated)"
			}
			c.Log(fmt.Sprintf("%s -> %q", name, body))
		}
	}
}
开发者ID:zhouqt,项目名称:juju,代码行数:44,代码来源:legacy_test.go

示例10: TestFatalf

func (s *FoundationS) TestFatalf(c *gocheck.C) {
	var line int
	defer (func() {
		if !c.Failed() {
			c.Error("Fatalf() didn't fail the test")
		} else {
			c.Succeed()
			expected := fmt.Sprintf("foundation_test.go:%d:\n"+
				"    c.Fatalf(\"Die %%s!\", \"now\")\n"+
				"... Error: Die now!\n\n",
				line)
			if c.GetTestLog() != expected {
				c.Error("Incorrect log:", c.GetTestLog())
			}
		}
	})()

	line = getMyLine() + 1
	c.Fatalf("Die %s!", "now")
	c.Log("Fatalf() didn't stop the test")
}
开发者ID:evaluation-alex,项目名称:gosync,代码行数:21,代码来源:foundation_test.go

示例11: TestReadMetaline

func (s *S) TestReadMetaline(c *check.C) {
	obtain := []interface{}{}
	if r, err := NewReaderName(G[1]); err != nil {
		c.Fatalf("Failed to open %q: %s", G[1], err)
	} else {
		r.TimeFormat = "Mon Jan _2 15:04:05 MST 2006"
		for i := 0; i < 3; i++ {
			for {
				if f, err := r.Read(); err != nil {
					if err == io.EOF {
						break
					} else {
						c.Fatalf("Failed to read %q: %s", G[1], err)
					}
				} else {
					obtain = append(obtain, f.Meta)
				}
			}
			if c.Failed() {
				break
			}
			if len(obtain) == len(expectMeta) {
				for j := range obtain {
					c.Check(obtain[j], check.DeepEquals, expectMeta[j])
				}
			} else {
				c.Check(len(obtain), check.Equals, len(expectMeta))
			}
			obtain = nil
			if err = r.Rewind(); err != nil {
				c.Fatalf("Failed to rewind %s", err)
			}
		}
		c.Check(r.SourceVersion, check.Equals, "<source> <version-text>")
		c.Check(r.Date.Format(r.TimeFormat), check.Equals, "Mon Jan  2 15:04:05 MST 2006")
		c.Check(r.Type, check.Equals, bio.Undefined)
		r.Close()
	}
}
开发者ID:frogs,项目名称:biogo,代码行数:39,代码来源:gff_test.go

示例12: TestReadBed

func (s *S) TestReadBed(c *check.C) {
	obtain := []*feat.Feature{}
	for k, b := range B {
		if r, err := NewReaderName(b.bName, b.bType); err != nil {
			c.Fatalf("Failed to open %q: %s", b.bName, err)
		} else {
			for i := 0; i < 3; i++ {
				for {
					if f, err := r.Read(); err != nil {
						if err == io.EOF {
							break
						} else {
							c.Fatalf("Failed to read %q: %s", b.bName, err)
						}
					} else {
						obtain = append(obtain, f)
					}
				}
				if c.Failed() {
					break
				}
				if len(obtain) == len(expect[k]) {
					for j := range obtain {
						c.Check(*obtain[j], check.DeepEquals, expect[k][j])
					}
				} else {
					c.Log(k, b)
					c.Check(len(obtain), check.Equals, len(expect[k]))
				}
				if err = r.Rewind(); err != nil {
					c.Fatalf("Failed to Rewind: %s", err)
				}
				obtain = nil
			}
			r.Close()
		}
	}
}
开发者ID:frogs,项目名称:biogo,代码行数:38,代码来源:bed_test.go

示例13: checkState

// Verify the state of the test.  Note that since this also verifies if
// the test is supposed to be in a failed state, no other checks should
// be done in addition to what is being tested.
func checkState(c *gocheck.C, result interface{}, expected *expectedState) {
	failed := c.Failed()
	c.Succeed()
	log := c.GetTestLog()
	matched, matchError := regexp.MatchString("^"+expected.log+"$", log)
	if matchError != nil {
		c.Errorf("Error in matching expression used in testing %s",
			expected.name)
	} else if !matched {
		c.Errorf("%s logged %#v which doesn't match %#v",
			expected.name, log, expected.log)
	}
	if result != expected.result {
		c.Errorf("%s returned %#v rather than %#v",
			expected.name, result, expected.result)
	}
	if failed != expected.failed {
		if failed {
			c.Errorf("%s has failed when it shouldn't", expected.name)
		} else {
			c.Errorf("%s has not failed when it should", expected.name)
		}
	}
}
开发者ID:CloudMarc,项目名称:mgo,代码行数:27,代码来源:gocheck_test.go

示例14: TestWatchCollection

func (s *FastPeriodSuite) TestWatchCollection(c *gc.C) {
	chA1 := make(chan watcher.Change)
	chB1 := make(chan watcher.Change)
	chA := make(chan watcher.Change)
	chB := make(chan watcher.Change)

	s.w.Watch("testA", 1, -1, chA1)
	s.w.Watch("testB", 1, -1, chB1)
	s.w.WatchCollection("testA", chA)
	s.w.WatchCollection("testB", chB)

	revno1 := s.insert(c, "testA", 1)
	revno2 := s.insert(c, "testA", 2)
	revno3 := s.insert(c, "testB", 1)
	revno4 := s.insert(c, "testB", 2)

	s.w.StartSync()

	seen := map[chan<- watcher.Change][]watcher.Change{}
	timeout := time.After(testing.LongWait)
	n := 0
Loop1:
	for n < 6 {
		select {
		case chg := <-chA1:
			seen[chA1] = append(seen[chA1], chg)
		case chg := <-chB1:
			seen[chB1] = append(seen[chB1], chg)
		case chg := <-chA:
			seen[chA] = append(seen[chA], chg)
		case chg := <-chB:
			seen[chB] = append(seen[chB], chg)
		case <-timeout:
			break Loop1
		}
		n++
	}

	c.Check(seen[chA1], gc.DeepEquals, []watcher.Change{{"testA", 1, revno1}})
	c.Check(seen[chB1], gc.DeepEquals, []watcher.Change{{"testB", 1, revno3}})
	c.Check(seen[chA], gc.DeepEquals, []watcher.Change{{"testA", 1, revno1}, {"testA", 2, revno2}})
	c.Check(seen[chB], gc.DeepEquals, []watcher.Change{{"testB", 1, revno3}, {"testB", 2, revno4}})
	if c.Failed() {
		return
	}

	s.w.UnwatchCollection("testB", chB)
	s.w.Unwatch("testB", 1, chB1)

	revno1 = s.update(c, "testA", 1)
	revno3 = s.update(c, "testB", 1)

	s.w.StartSync()

	timeout = time.After(testing.LongWait)
	seen = map[chan<- watcher.Change][]watcher.Change{}
	n = 0
Loop2:
	for n < 2 {
		select {
		case chg := <-chA1:
			seen[chA1] = append(seen[chA1], chg)
		case chg := <-chB1:
			seen[chB1] = append(seen[chB1], chg)
		case chg := <-chA:
			seen[chA] = append(seen[chA], chg)
		case chg := <-chB:
			seen[chB] = append(seen[chB], chg)
		case <-timeout:
			break Loop2
		}
		n++
	}
	c.Check(seen[chA1], gc.DeepEquals, []watcher.Change{{"testA", 1, revno1}})
	c.Check(seen[chB1], gc.IsNil)
	c.Check(seen[chA], gc.DeepEquals, []watcher.Change{{"testA", 1, revno1}})
	c.Check(seen[chB], gc.IsNil)

	// Check that no extra events arrive.
	seen = map[chan<- watcher.Change][]watcher.Change{}
	timeout = time.After(testing.ShortWait)
Loop3:
	for {
		select {
		case chg := <-chA1:
			seen[chA1] = append(seen[chA1], chg)
		case chg := <-chB1:
			seen[chB1] = append(seen[chB1], chg)
		case chg := <-chA:
			seen[chA] = append(seen[chA], chg)
		case chg := <-chB:
			seen[chB] = append(seen[chB], chg)
		case <-timeout:
			break Loop3
		}
	}
	c.Check(seen[chA1], gc.IsNil)
	c.Check(seen[chB1], gc.IsNil)
	c.Check(seen[chA], gc.IsNil)
	c.Check(seen[chB], gc.IsNil)
//.........这里部分代码省略.........
开发者ID:klyachin,项目名称:juju,代码行数:101,代码来源:watcher_test.go


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