-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtabulate_test.go
73 lines (67 loc) · 1.75 KB
/
tabulate_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/***************************************************************
*
* Copyright (c) 2015, Menglong TAN <[email protected]>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the BSD licence
*
**************************************************************/
/**
*
*
* @file tabulate_test.go
* @author Menglong TAN <[email protected]>
* @date Sat Oct 10 11:20:17 2015
*
**/
package gotabulate
import (
"fmt"
"testing"
)
func printStyleTable(format string) {
tabulator := NewTabulator()
fmt.Printf("%s\n", format)
tabulator.SetHeader([]string{"id", "name", "age"})
tabulator.SetFormat(format)
fmt.Print(
tabulator.Tabulate(
[][]string{
[]string{"long long long id 1", "crackcell", "27"},
[]string{"2", "crackcell2", "27"},
[]string{"3", "crackcell3", "27", "redundant cell"},
[]string{"4"},
[]string{"5", "crackcell5"}},
))
fmt.Println()
}
func printStyleTableFirstRow(format string) {
tabulator := NewTabulator()
fmt.Printf("%s\n", format)
tabulator.SetFirstRowHeader(true)
tabulator.SetFormat(format)
fmt.Print(
tabulator.Tabulate(
[][]string{
[]string{"long long long id 1", "crackcell", "27"},
[]string{"2", "crackcell2", "27"},
[]string{"3", "crackcell3", "27", "redundant cell"},
[]string{"4"},
[]string{"5", "crackcell5"}},
))
fmt.Println()
}
func TestTabluateAllStyle(t *testing.T) {
printStyleTable("simple")
printStyleTableFirstRow("simple")
printStyleTable("orgtbl")
printStyleTableFirstRow("orgtbl")
printStyleTable("pipe")
printStyleTableFirstRow("pipe")
printStyleTable("plain")
printStyleTableFirstRow("plain")
printStyleTable("psql")
printStyleTableFirstRow("psql")
printStyleTable("grid")
printStyleTableFirstRow("grid")
}