示例#1
0
func TestColWidthAutoWrap(t *testing.T) {
	tables.New([]Language3{
		{"Gooooooooooooooooooooooooooooooooooooooooooooooooo", 2009, "http://golang.org/"},
		{"Scala", 2003, "www.scala-lang.org/"},
		{"Haskell", 1990, "https://www.haskell.org/"},
	}).SetAlign(tables.ALIGN_CENTER).Render(os.Stdout)
}
示例#2
0
func TestFmt(t *testing.T) {
	tables.New([]Language2{
		{"Go", 2009, "http://golang.org/"},
		{"Scala", 2003, "www.scala-lang.org/"},
		{"Haskell", 1990, "https://www.haskell.org/"},
	}).Render(os.Stdout)
}
示例#3
0
func TestMap(t *testing.T) {
	tables.New(map[int]string{
		1990: "Haskell",
		2003: "Scala",
		2009: "Go",
	}).Render(os.Stdout)
}
示例#4
0
func TestOptions(t *testing.T) {
	tables.New([]Language{
		{"Go", 2009, "http://golang.org/"},
		{"Scala", 2003, "www.scala-lang.org/"},
		{"Haskell", 1990, "https://www.haskell.org/"},
	}).
		SetAlign(tables.ALIGN_CENTER). // align text in cell
		SetAutoWrap(false).            // wrap text to next line if it exceeds width limit
		SetCSeparator('x').            // center symbol for table
		SetHSeparator('=').            // horizontal symbol for table
		SetVSeparator('I').            // vertical symbol for table
		SetSplitHorizontally(false).   // split lines between
		SetWidthLimit(20).             // limit cell to n symbols
		SetPrintPointers(true).        // print raw pointers instead of their values
		Render(os.Stdout)
}
示例#5
0
func TestPrimitiveArray(t *testing.T) {
	arr := []int{11, 23, 10, 15, 78}
	tables.New(arr).Render(os.Stdout)
}
示例#6
0
func TestPrimitive(t *testing.T) {
	tables.New("hello").Render(os.Stdout)
	tables.New(1234567890).Render(os.Stdout)
	flt := 1.1
	tables.New(&flt).SetPrintPointers(true).Render(os.Stdout)
}
示例#7
0
func TestAutoWrap(t *testing.T) {
	tables.New(map[int]string{
		11111111111111111: "o",
		2:                 "a really long message, which will be split into multiple lines",
	}).SetWidthLimit(20).SetAlign(tables.ALIGN_CENTER).Render(os.Stdout)
}
示例#8
0
func TestStruct(t *testing.T) {
	tables.New(Language{"Go", 2009, "http://golang.org/"}).Render(os.Stdout)
}
示例#9
0
func TestEmpty(t *testing.T) {
	if tables.New([]TimeInfo{}).Render(os.Stdout) {
		t.Fatal("Should return false - has no data")
	}
}
示例#10
0
func TestCustomFormatter(t *testing.T) {
	tables.New([]TimeInfo{
		{time.Now(), "Current Time"},
		{time.Date(2000, 1, 1, 0, 0, 0, 0, time.Now().Location()), "New Millennium"},
	}).FormatColumn(timeFmt, "Time").Render(os.Stdout)
}