本文整理匯總了Golang中github.com/rjkroege/wikitools/testhelpers.AssertString函數的典型用法代碼示例。如果您正苦於以下問題:Golang AssertString函數的具體用法?Golang AssertString怎麽用?Golang AssertString使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AssertString函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Test_Dropcrnl
func Test_Dropcrnl(t *testing.T) {
testhelpers.AssertString(t, "", string(Dropcrnl([]byte(""))))
testhelpers.AssertString(t, "h", string(Dropcrnl([]byte("h"))))
testhelpers.AssertString(t, "hello", string(Dropcrnl([]byte("hello"))))
testhelpers.AssertString(t, "hello\nthere", string(Dropcrnl([]byte("hello\r\nthere"))))
testhelpers.AssertString(t, "hello\nthere", string(Dropcrnl([]byte("hello\nthere"))))
}
示例2: Test_Runemodulus
func Test_Runemodulus(t *testing.T) {
b, r := Runemodulus([]byte("abcd"))
testhelpers.AssertString(t, "abcd", string(b))
testhelpers.AssertInt(t, 0, len(r))
// 日本語 <- 3 Asian letters.
s := "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e"
sb := []byte(s)
b, r = Runemodulus(sb)
testhelpers.AssertString(t, s, string(b))
testhelpers.AssertInt(t, 0, len(r))
b, r = Runemodulus(sb[:len(sb)-1])
testhelpers.AssertString(t, s[0:6], string(b))
testhelpers.AssertInt(t, 2, len(r))
testhelpers.AssertInt(t, int(int(r[0])), '\xe8')
testhelpers.AssertInt(t, int(int(r[1])), '\xaa')
b, r = Runemodulus(sb[:len(sb)-2])
testhelpers.AssertInt(t, 1, len(r))
testhelpers.AssertString(t, s[0:6], string(b))
testhelpers.AssertInt(t, int(r[0]), '\xe8')
}
示例3: Test_VerifyRequiredFields_inbook_editor
func Test_VerifyRequiredFields_inbook_editor(t *testing.T) {
err := VerifyRequiredFields("inbook", []string{"bibkey", "author", "title", "chapter", "publisher", "year"})
if err != nil {
t.Error("wrongly claim that valid author/chapter inbook keys are invalid: " + err.Error())
}
err = VerifyRequiredFields("inbook", []string{"bibkey", "editor", "title", "chapter", "publisher", "year"})
if err != nil {
t.Error("wrongly claim that valid editor/chapter inbook keys are invalid: " + err.Error())
}
err = VerifyRequiredFields("inbook", []string{"bibkey", "author", "title", "pages", "publisher", "year"})
if err != nil {
t.Error("wrongly claim that valid author/pages inbook keys are invalid: " + err.Error())
}
err = VerifyRequiredFields("inbook", []string{"bibkey", "editor", "title", "pages", "publisher", "year"})
if err != nil {
t.Error("wrongly claim that valid editor/pages inbook keys are invalid: " + err.Error())
}
err = VerifyRequiredFields("inbook", []string{"bibkey", "editor", "title", "publisher", "year"})
if err == nil {
t.Error("for editor inbook, wrongly claim missing both pages and chapter is correct")
} else {
testhelpers.AssertString(t, "Missing required fields: chapter pages for entry type inbook", err.Error())
}
err = VerifyRequiredFields("inbook", []string{"bibkey", "author", "title", "publisher", "year"})
if err == nil {
t.Error("for author inbook, wrongly claim missing both pages and chapter is correct")
} else {
testhelpers.AssertString(t, "Missing required fields: chapter pages for entry type inbook", err.Error())
}
}
示例4: Test_UniqueValidName
func Test_UniqueValidName(t *testing.T) {
realisticdate, _ := article.ParseDateUnix("1999/03/21 17:00:00")
nd := &MockSystem{false, time.Time{}}
testhelpers.AssertString(t, "hello/there.md", UniqueValidName("hello/", "there", ".md", nd))
nd = &MockSystem{true, realisticdate}
testhelpers.AssertString(t, "hello/there-19990321-170000.md", UniqueValidName("hello/", "there", ".md", nd))
}
示例5: Test_Delete_spanning_offset
func Test_Delete_spanning_offset(t *testing.T) {
ws := New()
ws.Move(2)
ws.Addtyping([]byte{'a', 'b', 'c'}, 2)
testhelpers.AssertString(t, "abc", ws.String())
n := ws.Delete(1, 3)
testhelpers.AssertString(t, "bc", ws.String())
testhelpers.AssertInt(t, 1, n)
}
示例6: Test_ExtraKeysString
func Test_ExtraKeysString(t *testing.T) {
m := MetaData{"", never, never, "", false, []string{}, map[string]string{"a": "b"}}
testhelpers.AssertString(t, "a:b", m.ExtraKeysString())
m = MetaData{"", never, never, "", false, []string{}, map[string]string{"a": "b", "c": "d"}}
testhelpers.AssertString(t, "a:b, c:d", m.ExtraKeysString())
m = MetaData{"", never, never, "", false, []string{}, map[string]string{"c": "d", "a": "b"}}
testhelpers.AssertString(t, "a:b, c:d", m.ExtraKeysString())
}
示例7: Test_PrettyDate
func Test_PrettyDate(t *testing.T) {
statdate, _ := ParseDateUnix("1999/03/21 17:00:00")
tagdate, _ := ParseDateUnix("2012/03/19 06:51:15")
md := MetaData{"", statdate, never, "What I want 0", false, []string{}, map[string]string{}}
testhelpers.AssertString(t, "Sunday, Mar 21, 1999", md.PrettyDate())
md = MetaData{"", statdate, tagdate, "What I want 0", true, []string{}, map[string]string{}}
testhelpers.AssertString(t, "Monday, Mar 19, 2012", md.PrettyDate())
}
示例8: Test_Delete_multi
func Test_Delete_multi(t *testing.T) {
ws := New()
ws.Move(2)
ws.Addtyping([]byte{'a', 'b', 'c'}, 2)
testhelpers.AssertString(t, "abc", ws.String())
n := ws.Delete(3, 5)
testhelpers.AssertString(t, "a", ws.String())
testhelpers.AssertInt(t, 0, n)
}
示例9: Test_Sendtype
func Test_Sendtype(t *testing.T) {
mock := &mockttyfd{make([][]byte, 0, 10)}
tp := New(mock, Makecho())
tp.addtype([]byte("hello\nbye"), 0, false)
tp.Sendtype()
testhelpers.AssertInt(t, 1, len(mock.writes))
testhelpers.AssertString(t, "hello\n", string(mock.writes[0]))
testhelpers.AssertString(t, "bye", string(tp.Typing))
}
示例10: Test_TypeCook
func Test_TypeCook(t *testing.T) {
mock := &mockttyfd{make([][]byte, 0, 10)}
tp := New(mock, Makecho())
s := "hello\n"
e := &acme.Event{Nr: len(s), Text: []byte(s)}
tp.Type(e)
testhelpers.AssertInt(t, 1, len(mock.writes))
testhelpers.AssertString(t, "hello\n", string(mock.writes[0]))
testhelpers.AssertString(t, "", string(tp.Typing))
testhelpers.AssertBool(t, true, tp.cook)
}
示例11: Test_Cancel_Wholeword
func Test_Cancel_Wholeword(t *testing.T) {
echo := Makecho()
echo.echoed([]byte("hello"))
s := []byte("h")
r := echo.Cancel(s)
testhelpers.AssertInt(t, 0, len(r))
testhelpers.AssertString(t, "ello", string(echo.oldest))
s = []byte("e")
r = echo.Cancel(s)
testhelpers.AssertInt(t, 0, len(r))
testhelpers.AssertString(t, "llo", string(echo.oldest))
}
示例12: Test_ExploreTemplating
func Test_ExploreTemplating(t *testing.T) {
s, e := CreateBibTexEntry([]string{"@book"}, map[string]string{"bib-bibkey": "jones2013", "bib-editor": "Peyton Jones", "bib-title": "Collected Angst", "bib-publisher": "Penguin", "bib-year": "2013"})
if e != nil {
t.Error("CreateBibTexEntry wrongly failed with: " + e.Error())
}
testhelpers.AssertString(t, output1, s)
s, e = CreateBibTexEntry([]string{"@book", "@bibtex-article"}, map[string]string{"bib-bibkey": "jones2013", "bib-editor": "Peyton Jones", "bib-title": "Collected Angst", "bib-publisher": "Penguin", "bib-year": "2013"})
if e == nil {
t.Error("CreateBibTexEntry wrongly succeeded")
} else {
testhelpers.AssertString(t, "", s)
testhelpers.AssertString(t, "Missing required fields: author journal for entry type article", e.Error())
}
}
示例13: Test_addtype
func Test_addtype(t *testing.T) {
tp := New(new(mockttyfd), Makecho())
tp.addtype([]byte("hello"), 0, false)
testhelpers.AssertString(t, "hello", tp.String())
// addtype is doing the wrong thing...
tp.addtype([]byte{3}, len("hello"), false)
testhelpers.AssertString(t, "hello", tp.String())
// addtype is doing the wrong thing...
tp.addtype([]byte{3}, len("hello_"), true)
testhelpers.AssertString(t, "", tp.String())
}
示例14: Test_Labelcommand_hasend_with_space
func Test_Labelcommand_hasend_with_space(t *testing.T) {
b, r := Labelcommand([]byte("hel\007lo"))
if r != nil {
t.Error("incomplete command should have no label")
}
testhelpers.AssertString(t, "hel\007lo", string(b))
}
示例15: Test_Delete_before_offset
func Test_Delete_before_offset(t *testing.T) {
ws := New()
ws.Move(2)
n := ws.Delete(1, 2)
testhelpers.AssertString(t, "", ws.String())
testhelpers.AssertInt(t, 1, n)
}