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) }
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) }
func TestMap(t *testing.T) { tables.New(map[int]string{ 1990: "Haskell", 2003: "Scala", 2009: "Go", }).Render(os.Stdout) }
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) }
func TestPrimitiveArray(t *testing.T) { arr := []int{11, 23, 10, 15, 78} tables.New(arr).Render(os.Stdout) }
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) }
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) }
func TestStruct(t *testing.T) { tables.New(Language{"Go", 2009, "http://golang.org/"}).Render(os.Stdout) }
func TestEmpty(t *testing.T) { if tables.New([]TimeInfo{}).Render(os.Stdout) { t.Fatal("Should return false - has no data") } }
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) }