本文整理汇总了Golang中github.com/cheekybits/is.True函数的典型用法代码示例。如果您正苦于以下问题:Golang True函数的具体用法?Golang True怎么用?Golang True使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了True函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestNewWriter_1Sample
func TestNewWriter_1Sample(t *testing.T) {
t.Parallel()
is := is.New(t)
f, err := ioutil.TempFile("", "wavPkgtest")
is.NoErr(err)
wr, err := wf.NewWriter(f)
is.NoErr(err)
err = wr.WriteSample([]byte{1, 1})
is.NoErr(err)
is.Nil(wr.Close())
f, err = os.Open(f.Name())
is.NoErr(err)
b, err := ioutil.ReadAll(f)
is.NoErr(err)
is.Equal(len(b), 46)
is.True(bytes.Contains(b, riff))
is.True(bytes.Contains(b, wave))
is.True(bytes.Contains(b, fmt20))
is.Nil(os.Remove(f.Name()))
}
示例2: TestValueEqual
func TestValueEqual(t *testing.T) {
is := is.New(t)
v := ParseValue([]byte("something"))
is.True(v.Equal("something"))
is.False(v.Equal("else"))
is.Equal("string", v.Type())
v = ParseValue([]byte("123"))
is.Equal("float64", v.Type())
v = ParseValue([]byte("/^2.{2}$/"))
is.True(v.Equal(200))
is.True(v.Equal(201))
is.False(v.Equal(404))
is.Equal("regex", v.Type())
v = ParseValue([]byte("/application/json/"))
is.True(v.Equal("application/json"))
is.True(v.Equal("application/json; charset=utf-8"))
is.True(v.Equal("text/xml; application/json; charset=utf-8"))
is.False(v.Equal("text/xml; charset=utf-8"))
is.Equal("regex", v.Type())
is.Equal(`/application/json/`, v.String())
v = ParseValue([]byte("/Silk/"))
is.True(v.Equal("My name is Silk."))
is.True(v.Equal("Silk is my name."))
is.False(v.Equal("I don't contain that word!"))
}
示例3: TestFileList
func TestFileList(t *testing.T) {
is := is.New(t)
s := NewShell(shellUrl)
list, err := s.FileList(fmt.Sprintf("/ipfs/%s", examplesHash))
is.Nil(err)
is.Equal(list.Type, "Directory")
is.Equal(list.Size, 0)
is.Equal(len(list.Links), 6)
// TODO: document difference in sice betwen 'ipfs ls' and 'ipfs file ls -v'. additional object encoding in data block?
expected := map[string]UnixLsLink{
"about": {Type: "File", Hash: "QmZTR5bcpQD7cFgTorqxZDYaew1Wqgfbd2ud9QqGPAkK2V", Name: "about", Size: 1677},
"contact": {Type: "File", Hash: "QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y", Name: "contact", Size: 189},
"help": {Type: "File", Hash: "QmY5heUM5qgRubMDD1og9fhCPA6QdkMp3QCwd4s7gJsyE7", Name: "help", Size: 311},
"quick-start": {Type: "File", Hash: "QmUzLxaXnM8RYCPEqLDX5foToi5aNZHqfYr285w2BKhkft", Name: "quick-start", Size: 1686},
"readme": {Type: "File", Hash: "QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB", Name: "readme", Size: 1091},
"security-notes": {Type: "File", Hash: "QmTumTjvcYCAvRRwQ8sDRxh8ezmrcr88YFU7iYNroGGTBZ", Name: "security-notes", Size: 1016},
}
for _, l := range list.Links {
el, ok := expected[l.Name]
is.True(ok)
is.NotNil(el)
is.Equal(*l, el)
}
}
示例4: TestMatch
func TestMatch(t *testing.T) {
is := is.New(t)
e1 := &testEncoder{}
e2 := &testEncoder{}
e3 := &testEncoder{}
e := encoding.New()
e.Default = respond.JSON
e.Add("json", e1)
e.Add("XML", e2)
// Match
json, ok := e.Match("application/JSON")
is.True(ok)
is.Equal(json, e1)
json = e.EncoderFunc(nil, testRequestWithAccept("application/json"))
is.Equal(json, e1)
xml, ok := e.Match("text/xml")
is.True(ok)
is.Equal(xml, e2)
xml = e.EncoderFunc(nil, testRequestWithAccept("text/xml"))
is.True(ok)
is.Equal(xml, e2)
// no responder
csv, ok := e.Match("text/csv")
is.False(ok)
is.Nil(csv)
csv = e.EncoderFunc(nil, testRequestWithAccept("text/csv"))
is.Nil(csv)
is.Equal(e.Default, csv)
// add
e.Add("csv", e3)
csv, ok = e.Match("text/xml")
is.True(ok)
is.Equal(csv, e3)
// remove
e.Del(e2)
xml, ok = e.Match("text/xml")
is.False(ok)
is.Nil(xml)
}
示例5: TestFailureFieldsDifferentTypes
func TestFailureFieldsDifferentTypes(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoHandler())
defer s.Close()
r := runner.New(subT, s.URL)
var logs []string
r.Log = func(s string) {
logs = append(logs, s)
}
g, err := parse.ParseFile("../testfiles/failure/echo.failure.fieldsdifferenttypes.silk.md")
is.NoErr(err)
r.RunGroup(g...)
is.True(subT.Failed())
logstr := strings.Join(logs, "\n")
is.True(strings.Contains(logstr, `Status expected string: "400" actual float64: 200`))
}
示例6: TestGlob
func TestGlob(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoHandler())
defer s.Close()
r := runner.New(subT, s.URL)
r.Log = func(s string) {} // don't bother logging
r.RunGlob(filepath.Glob("../testfiles/failure/echo.*.silk.md"))
is.True(subT.Failed())
}
示例7: TestFailureWrongHeader
func TestFailureWrongHeader(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoHandler())
defer s.Close()
r := runner.New(subT, s.URL)
var logs []string
r.Log = func(s string) {
logs = append(logs, s)
}
g, err := parse.ParseFile("../testfiles/failure/echo.failure.wrongheader.silk.md")
is.NoErr(err)
r.RunGroup(g...)
is.True(subT.Failed())
logstr := strings.Join(logs, "\n")
is.True(strings.Contains(logstr, `Content-Type expected string: "wrong/type" actual string: "text/plain; charset=utf-8"`))
is.True(strings.Contains(logstr, "--- FAIL: GET /echo"))
is.True(strings.Contains(logstr, "../testfiles/failure/echo.failure.wrongheader.silk.md:22 - Content-Type doesn't match"))
}
示例8: TestFailureNonTrimmedExpection
// https://github.com/matryer/silk/issues/28
func TestFailureNonTrimmedExpection(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoDataHandler())
defer s.Close()
r := runner.New(subT, s.URL)
var logs []string
r.Log = func(s string) {
logs = append(logs, s)
}
g, err := parse.ParseFile("../testfiles/failure/echo.failure.nontrimmedexpectation.silk.md")
is.NoErr(err)
r.RunGroup(g...)
is.True(subT.Failed())
logstr := strings.Join(logs, "\n")
is.True(strings.Contains(logstr, `Data.body.status expected: "awesome" actual: " awesome"`))
is.True(strings.Contains(logstr, "--- FAIL: GET /echo"))
is.True(strings.Contains(logstr, "../testfiles/failure/echo.failure.nontrimmedexpectation.silk.md:18 - Data.body.status doesn't match"))
}
示例9: TestRunJsonModesFailure
func TestRunJsonModesFailure(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoRawHandler())
defer s.Close()
r := runner.New(subT, s.URL)
g, err := parse.ParseFile("../testfiles/failure/echoraw.failure.jsonmodes.silk.md")
is.NoErr(err)
r.RunGroup(g...)
is.True(subT.Failed())
}
示例10: TestValueEqual
func TestValueEqual(t *testing.T) {
is := is.New(t)
v := ParseValue([]byte("something"))
is.True(v.Equal("something"))
is.False(v.Equal("else"))
is.Equal("string", v.Type())
v = ParseValue([]byte("123"))
is.Equal("float64", v.Type())
v = ParseValue([]byte("/^2.{2}$/"))
is.True(v.Equal(200))
is.True(v.Equal(201))
is.False(v.Equal(404))
is.Equal("regex", v.Type())
v = ParseValue([]byte("/application/json/"))
is.True(v.Equal("application/json"))
is.True(v.Equal("application/json; charset=utf-8"))
is.True(v.Equal("text/xml; application/json; charset=utf-8"))
is.False(v.Equal("text/xml; charset=utf-8"))
is.Equal("regex", v.Type())
}
示例11: TestIDSliceSearchIDs
func TestIDSliceSearchIDs(t *testing.T) {
is := is.New(t)
var ids asset.IDSlice
id1, err := asset.Identify(strings.NewReader("foo"))
is.NoErr(err)
id2, err := asset.Identify(strings.NewReader("bar"))
is.NoErr(err)
id3, err := asset.Identify(strings.NewReader("baz"))
is.NoErr(err)
ids.Push(id1)
ids.Push(id2)
ids.Push(id3)
ids.Sort()
is.True(id2.Less(id1))
is.True(id3.Less(id2))
is.Equal(asset.SearchIDs(ids, id1), 2)
is.Equal(asset.SearchIDs(ids, id2), 1)
is.Equal(asset.SearchIDs(ids, id3), 0)
}
示例12: TestJvInvalidWithMessage_string
func TestJvInvalidWithMessage_string(t *testing.T) {
is := is.New(t)
jv := jq.JvInvalidWithMessage(jq.JvFromString("Error message 1"))
is.False(jv.IsValid())
msg := jv.Copy().GetInvalidMessage()
is.Equal(msg.Kind(), jq.JV_KIND_STRING)
msg.Free()
str, ok := jv.GetInvalidMessageAsString()
is.True(ok)
is.Equal("Error message 1", str)
}
示例13: TestJvInvalidWithMessage_object
func TestJvInvalidWithMessage_object(t *testing.T) {
is := is.New(t)
jv := jq.JvInvalidWithMessage(jq.JvObject())
is.False(jv.IsValid())
msg := jv.Copy().GetInvalidMessage()
is.Equal(msg.Kind(), jq.JV_KIND_OBJECT)
msg.Free()
str, ok := jv.GetInvalidMessageAsString()
is.True(ok)
is.Equal("{}", str)
}
示例14: TestFailureWrongBody
func TestFailureWrongBody(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoHandler())
defer s.Close()
r := runner.New(subT, s.URL)
var logs []string
r.Log = func(s string) {
logs = append(logs, s)
}
g, err := parse.ParseFile("../testfiles/failure/echo.failure.wrongbody.silk.md")
is.NoErr(err)
r.RunGroup(g...)
is.True(subT.Failed())
logstr := strings.Join(logs, "\n")
is.True(strings.Contains(logstr, "body expected:"))
is.True(strings.Contains(logstr, "GET /echo"))
is.True(strings.Contains(logstr, "Hello silky."))
is.True(strings.Contains(logstr, "actual:"))
is.True(strings.Contains(logstr, "GET /echo"))
is.True(strings.Contains(logstr, "Hello silk."))
is.True(strings.Contains(logstr, "--- FAIL: GET /echo"))
is.True(strings.Contains(logstr, "../testfiles/failure/echo.failure.wrongbody.silk.md:14 - body doesn't match"))
}
示例15: TestSum
func TestSum(t *testing.T) {
is := is.New(t)
id1, err := asset.Identify(strings.NewReader("foo"))
is.NoErr(err)
id2, err := asset.Identify(strings.NewReader("bar"))
is.NoErr(err)
is.True(id2.Less(id1))
sr := strings.NewReader(id2.String() + id1.String())
expectedSum, err := asset.Identify(sr)
is.NoErr(err)
testSum, err := id1.Sum(id2)
is.NoErr(err)
is.Equal(expectedSum, testSum)
}