本文整理匯總了Golang中launchpad/net/gocheck.Commentf函數的典型用法代碼示例。如果您正苦於以下問題:Golang Commentf函數的具體用法?Golang Commentf怎麽用?Golang Commentf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Commentf函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestApplication
func (cs *CompilerSuite) TestApplication(c *gc.C) {
expr := parseAndExpandForTest(`(+ 1 2 3)`, c)
name := "TestApplication"
code, err := Compile(name, expr)
c.Assert(err, gc.IsNil, gc.Commentf("failed to compile code: %s", err))
c.Assert(code, gc.NotNil, gc.Commentf("failed to produce code"))
c.Check(code.Name(), gc.Equals, name)
c.Assert(code.CodeLen(), gc.Equals, uint(5))
c.Assert(code.SymbolLen(), gc.Equals, uint(1))
c.Assert(code.ConstantLen(), gc.Equals, uint(3))
c.Check(code.GetInstruction(0).Code(), gc.Equals, OP_CONST)
c.Check(code.GetInstruction(0).Argument(), gc.Equals, uint(0))
c.Check(code.GetInstruction(1).Code(), gc.Equals, OP_CONST)
c.Check(code.GetInstruction(1).Argument(), gc.Equals, uint(1))
c.Check(code.GetInstruction(2).Code(), gc.Equals, OP_CONST)
c.Check(code.GetInstruction(2).Argument(), gc.Equals, uint(2))
c.Check(code.GetInstruction(3).Code(), gc.Equals, OP_LOADVAR)
c.Check(code.GetInstruction(3).Argument(), gc.Equals, uint(0))
c.Check(code.GetInstruction(4).Code(), gc.Equals, OP_CALL)
c.Check(code.GetInstruction(4).Argument(), gc.Equals, uint(3))
num := code.GetConstant(0).(Integer)
c.Check(num.ToInteger(), gc.Equals, int64(1))
num = code.GetConstant(1).(Integer)
c.Check(num.ToInteger(), gc.Equals, int64(2))
num = code.GetConstant(2).(Integer)
c.Check(num.ToInteger(), gc.Equals, int64(3))
c.Check(code.GetSymbol(0).String(), gc.Equals, "+")
}
示例2: TestCar
func (ps *PairSuite) TestCar(c *gc.C) {
c.Check(Car(nil), gc.IsNil, gc.Commentf("Car(nil) should be nil"))
c.Check(Car("foo"), gc.IsNil, gc.Commentf(`Car("foo") should be nil`))
foo := NewSymbol("foo")
p := NewPair(foo)
c.Check(Car(p), gc.Equals, foo, gc.Commentf(`Car() should return first of list`))
}
示例3: TestIfElse
func (cs *CompilerSuite) TestIfElse(c *gc.C) {
expr := parseAndExpandForTest(`(if #t 1 2)`, c)
name := "TestIfElse"
code, err := Compile(name, expr)
c.Assert(err, gc.IsNil, gc.Commentf("failed to compile code: %s", err))
c.Assert(code, gc.NotNil, gc.Commentf("failed to produce code"))
c.Assert(code.CodeLen(), gc.Equals, uint(5))
c.Check(code.GetInstruction(0).Code(), gc.Equals, OP_CONST)
c.Check(code.GetInstruction(0).Argument(), gc.Equals, uint(0))
c.Check(code.GetInstruction(1).Code(), gc.Equals, OP_FJUMP)
c.Check(code.GetInstruction(1).Argument(), gc.Equals, uint(4))
c.Check(code.GetInstruction(2).Code(), gc.Equals, OP_CONST)
c.Check(code.GetInstruction(2).Argument(), gc.Equals, uint(1))
c.Check(code.GetInstruction(3).Code(), gc.Equals, OP_JUMP)
c.Check(code.GetInstruction(3).Argument(), gc.Equals, uint(5))
c.Check(code.GetInstruction(4).Code(), gc.Equals, OP_CONST)
c.Check(code.GetInstruction(4).Argument(), gc.Equals, uint(2))
c.Check(code.Name(), gc.Equals, name)
c.Assert(code.SymbolLen(), gc.Equals, uint(0))
c.Assert(code.ConstantLen(), gc.Equals, uint(3))
boo := code.GetConstant(0).(Boolean)
c.Check(boo.Value(), gc.Equals, true)
num := code.GetConstant(1).(Integer)
c.Check(num.ToInteger(), gc.Equals, int64(1))
num = code.GetConstant(2).(Integer)
c.Check(num.ToInteger(), gc.Equals, int64(2))
}
示例4: TestParagraphUtf8Span
func (s *TestSuite) TestParagraphUtf8Span(c *gocheck.C) {
text, _ := s.doc.GetStructuredTextFragment("utf8span")
p, _ := text.GetFirstParagraph()
c.Assert(p, gocheck.NotNil, gocheck.Commentf("Has a first paragraph"))
content := "<p>Thìs ìs <à> <em>tést</em>.</p>"
c.Assert(p.AsHtml(), gocheck.Equals, content, gocheck.Commentf("Has the right rendering"))
}
示例5: TestQuery
func (s *ApiTestSuite) TestQuery(c *gocheck.C) {
c.Assert(s.api, gocheck.NotNil, gocheck.Commentf("Connection with api is OK"))
sr, err := s.api.Master().Form("everything").Query("[[:d = at(document.tags, [\"Macaron\"])]]").Submit()
c.Assert(err, gocheck.IsNil, gocheck.Commentf("Submit did not return an error - %s", err))
c.Assert(len(sr.Results), gocheck.Equals, 7, gocheck.Commentf("Submit did return 7 documents"))
}
示例6: TestPreformattedEscape
func (s *TestSuite) TestPreformattedEscape(c *gocheck.C) {
text, _ := s.doc.GetStructuredTextFragment("escape")
p, _ := text.GetFirstPreformatted()
c.Assert(p, gocheck.NotNil, gocheck.Commentf("Has a first preformatted"))
content := "<pre>This is <a> test.</pre>"
c.Assert(p.AsHtml(), gocheck.Equals, content, gocheck.Commentf("Has the right rendering"))
}
示例7: TestParagraphEscapeAndSpan
func (s *TestSuite) TestParagraphEscapeAndSpan(c *gocheck.C) {
text, _ := s.doc.GetStructuredTextFragment("escapespan")
p, _ := text.GetFirstParagraph()
c.Assert(p, gocheck.NotNil, gocheck.Commentf("Has a first paragraph"))
content := "<p>Thi& i& <a> <em>test</em>.</p>"
c.Assert(p.AsHtml(), gocheck.Equals, content, gocheck.Commentf("Has the right rendering"))
}
示例8: TestGetBy
func (s *ProxyTestSuite) TestGetBy(c *gocheck.C) {
c.Assert(s.proxy, gocheck.NotNil, gocheck.Commentf("Connection with api is OK"))
d, err := s.proxy.GetDocumentBy("product", "flavour", "Pistachio")
c.Assert(d, gocheck.Not(gocheck.IsNil), gocheck.Commentf("Submit did not return an error - %s", err))
f, _ := d.GetTextFragment("flavour")
c.Assert(f.AsText(), gocheck.Equals, "Pistachio", gocheck.Commentf("Proxy returns the same doc"))
}
示例9: TestPreformattedRendering
func (s *TestSuite) TestPreformattedRendering(c *gocheck.C) {
text, _ := s.doc.GetStructuredTextFragment("render")
p, _ := text.GetFirstPreformatted()
c.Assert(p, gocheck.NotNil, gocheck.Commentf("Has a first preformatted"))
content := "<pre>This <em>is</em> <strong>a</strong> test.</pre>"
c.Assert(p.AsHtml(), gocheck.Equals, content, gocheck.Commentf("Has the right rendering"))
}
示例10: TestLRU
func (s *ProxyTestSuite) TestLRU(c *gocheck.C) {
c.Assert(s.proxy, gocheck.NotNil, gocheck.Commentf("Connection with api is OK"))
sr, err := s.proxy.Search().Form("products").Submit()
log.Printf("%#v", sr)
c.Assert(sr, gocheck.Not(gocheck.IsNil), gocheck.Commentf("Submit did not return an error - %s", err))
s.proxy.Clear()
stats := s.proxy.GetStats()
// accessing ds[0]
s.proxy.GetDocument(sr.Results[0].Id)
stats1 := s.proxy.GetStats()
c.Assert(stats1.Hit, gocheck.Equals, stats.Hit, gocheck.Commentf("on an empty cache, no hit"))
c.Assert(stats1.Miss, gocheck.Equals, stats.Miss+1, gocheck.Commentf("on an empty cache, miss"))
// accessing ds[0] again
s.proxy.GetDocument(sr.Results[0].Id)
stats1 = s.proxy.GetStats()
c.Assert(stats1.Hit, gocheck.Equals, stats.Hit+1, gocheck.Commentf("doc in cache, hit"))
c.Assert(stats1.Miss, gocheck.Equals, stats.Miss+1, gocheck.Commentf("doc in cache, no miss"))
// accessing another doc. LRU size is 1 => ds[0] should be evicted
s.proxy.GetDocument(sr.Results[1].Id)
stats1 = s.proxy.GetStats()
c.Assert(stats1.Hit, gocheck.Equals, stats.Hit+1, gocheck.Commentf("doc not in cache, no hit"))
c.Assert(stats1.Miss, gocheck.Equals, stats.Miss+2, gocheck.Commentf("doc not in cache, miss"))
// accessing ds[0] again, should not be found in cache
s.proxy.GetDocument(sr.Results[0].Id)
stats1 = s.proxy.GetStats()
c.Assert(stats1.Hit, gocheck.Equals, stats.Hit+1, gocheck.Commentf("doc evicted from cache, no hit"))
c.Assert(stats1.Miss, gocheck.Equals, stats.Miss+3, gocheck.Commentf("doc evicted from cache, miss"))
}
示例11: TestAtSet
func (s *S) TestAtSet(c *check.C) {
for test, af := range [][][]float64{
{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, // even
{{1, 2}, {4, 5}, {7, 8}}, // wide
{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, //skinny
} {
m := NewDense(flatten(af))
rows, cols := m.Dims()
for i := 0; i < rows; i++ {
for j := 0; j < cols; j++ {
c.Check(m.At(i, j), check.Equals, af[i][j], check.Commentf("At test %d", test))
v := float64(i * j)
m.Set(i, j, v)
c.Check(m.At(i, j), check.Equals, v, check.Commentf("Set test %d", test))
}
}
// Check access out of bounds fails
c.Check(func() { m.At(rows, 0) }, check.PanicMatches, "index error: row access out of bounds", check.Commentf("Test %d", test))
c.Check(func() { m.At(rows+1, 0) }, check.PanicMatches, "index error: row access out of bounds", check.Commentf("Test %d", test))
c.Check(func() { m.At(0, cols) }, check.PanicMatches, "index error: column access out of bounds", check.Commentf("Test %d", test))
c.Check(func() { m.At(0, cols+1) }, check.PanicMatches, "index error: column access out of bounds", check.Commentf("Test %d", test))
c.Check(func() { m.At(-1, 0) }, check.PanicMatches, "index error: row access out of bounds", check.Commentf("Test %d", test))
c.Check(func() { m.At(0, -1) }, check.PanicMatches, "index error: column access out of bounds", check.Commentf("Test %d", test))
// Check access out of bounds fails
c.Check(func() { m.Set(rows, 0, 1.2) }, check.PanicMatches, "index error: row access out of bounds", check.Commentf("Test %d", test))
c.Check(func() { m.Set(rows+1, 0, 1.2) }, check.PanicMatches, "index error: row access out of bounds", check.Commentf("Test %d", test))
c.Check(func() { m.Set(0, cols, 1.2) }, check.PanicMatches, "index error: column access out of bounds", check.Commentf("Test %d", test))
c.Check(func() { m.Set(0, cols+1, 1.2) }, check.PanicMatches, "index error: column access out of bounds", check.Commentf("Test %d", test))
c.Check(func() { m.Set(-1, 0, 1.2) }, check.PanicMatches, "index error: row access out of bounds", check.Commentf("Test %d", test))
c.Check(func() { m.Set(0, -1, 1.2) }, check.PanicMatches, "index error: column access out of bounds", check.Commentf("Test %d", test))
}
}
示例12: checkInterpret
// checkInterpret takes a map of inputs to expected outputs, running the
// inputs through the interpreter and checking the output.
func checkInterpret(c *gc.C, inputs map[string]string) {
for input, expected := range inputs {
result, err := Interpret(input)
c.Assert(err, gc.IsNil, gc.Commentf("Interpret() failed for %q: %v", input, err))
c.Check(stringify(result), gc.Equals, expected, gc.Commentf(input))
}
}
示例13: TestGetFirstPreformatted
func (s *TestSuite) TestGetFirstPreformatted(c *gocheck.C) {
text, _ := s.doc.GetStructuredTextFragment("description")
p, _ := text.GetFirstPreformatted()
c.Assert(p, gocheck.NotNil, gocheck.Commentf("Has a first preformatted"))
content := "If you ever met coconut taste on its bad day, you surely know that coconut, coming from bad-tempered islands, can be rough sometimes. That is why we like to soften it with a touch of caramel taste in its ganache. The result is the perfect encounter between the finest palm fruit and the most tasty of sugarcane's offspring."
c.Assert(p.Text, gocheck.Equals, content, gocheck.Commentf("Has the right content"))
}
示例14: checkInterpretError
// checkInterpretError takes a map of inputs to expected error messages,
// running the inputs through the interpreter and ensuring that each one fails
// with the associated error message.
func checkInterpretError(c *gc.C, inputs map[string]string) {
for input, expected := range inputs {
result, err := Interpret(input)
c.Assert(err, gc.NotNil, gc.Commentf("expected %q to fail, got %v", input, result))
c.Check(err, gc.ErrorMatches, expected, gc.Commentf(input))
}
}
示例15: TestGetBoolean
func (s *TestSuite) TestGetBoolean(c *gocheck.C) {
a, _ := s.doc.GetBool("adult")
c.Assert(a, gocheck.Equals, true, gocheck.Commentf("Found the right bool"))
a, _ = s.doc.GetBool("teenager")
c.Assert(a, gocheck.Equals, true, gocheck.Commentf("Found the right bool"))
a, _ = s.doc.GetBool("french")
c.Assert(a, gocheck.Equals, false, gocheck.Commentf("Found the right bool"))
}