-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add test for last column included in filter * add option to specify justification overrides to specified columns * add usage and justification examples * change flag to -i and use colon for overrides * update justification examples * fix usage output
- Loading branch information
1 parent
423ac4b
commit b671025
Showing
4 changed files
with
102 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,6 232,12 @@ var exportCases = []struct { | |
[]int{1, 3}, | ||
0, | ||
}, | ||
{ | ||
strings.NewReader("first,middle,last"), | ||
bytes.NewBufferString(""), | ||
[]int{1, 4}, | ||
0, | ||
}, | ||
{ | ||
strings.NewReader("first,middle,last"), | ||
bytes.NewBufferString(""), | ||
|
@@ -250,6 256,7 @@ var runCases = []struct { | |
dValue string | ||
aValue string | ||
cValue string | ||
iValue string | ||
shouldErr bool | ||
}{ | ||
{ | ||
|
@@ -260,10 267,30 @@ var runCases = []struct { | |
helpValue: true, | ||
shouldErr: true, | ||
}, | ||
{ | ||
iValue: "1:right,2:center", | ||
shouldErr: true, | ||
}, | ||
{ | ||
iValue: "1:left,2:,NaN:left", | ||
shouldErr: true, | ||
}, | ||
{ | ||
iValue: "3:noexist", | ||
shouldErr: true, | ||
}, | ||
{ | ||
cValue: "a2-right,NaN", | ||
shouldErr: true, | ||
}, | ||
{ | ||
cValue: "1,2", | ||
shouldErr: true, | ||
}, | ||
{ | ||
cValue: "1-left,2-right,3-center", | ||
shouldErr: true, | ||
}, | ||
{ | ||
cValue: "1,2,a", | ||
shouldErr: true, | ||
|
@@ -344,6 371,7 @@ func TestRun(t *testing.T) { | |
*aFlag = tt.aValue | ||
*cFlag = tt.cValue | ||
*qFlag = tt.qValue | ||
*iFlag = tt.iValue | ||
|
||
code, _ := run() | ||
|
||
|
@@ -408,7 436,7 @@ func TestSplit(t *testing.T) { | |
|
||
func TestPad(t *testing.T) { | ||
for _, tt := range paddingCases { | ||
got := pad(tt.input, 1, tt.columnCount, tt.po) | ||
got := pad(tt.input, 1, tt.columnCount, tt.po.Justification) | ||
|
||
if len(got) != tt.expected { | ||
t.Fatalf("pad(%v) =%v; want %v", tt.input, got, tt.expected) | ||
|
@@ -458,11 486,11 @@ func TestCountPadding(t *testing.T) { | |
func BenchmarkColumnCounts(b *testing.B) { | ||
input := `First,Middle,Last,Email,Region,City,Zip,Full_Name,First,Middle,Last,Email,Region,City,Zip,Full_Name,First,Middle,Last,Email,Region,City,Zip,Full_Name | ||
Karleigh,Destiny,Dean,[email protected],Stockholms län,Märsta,9038,Shaine Reilly,Karleigh,Destiny,Dean,[email protected],Stockholms län,Märsta,9038,Shaine Reilly,Karleigh,Destiny,Dean,[email protected],Stockholms län,Märsta,9038,Shaine Reilly | ||
Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez ,Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez ,Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez | ||
Karleigh,Destiny,Dean,[email protected],Stockholms län,Märsta,9038,Shaine Reilly,Karleigh,Destiny,Dean,[email protected],Stockholms län,Märsta,9038,Shaine Reilly,Karleigh,Destiny,Dean,[email protected],Stockholms län,Märsta,9038,Shaine Reilly | ||
Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez ,Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez ,Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez | ||
Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez ,Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez ,Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez | ||
Karleigh,Destiny,Dean,[email protected],Stockholms län,Märsta,9038,Shaine Reilly,Karleigh,Destiny,Dean,[email protected],Stockholms län,Märsta,9038,Shaine Reilly,Karleigh,Destiny,Dean,[email protected],Stockholms län,Märsta,9038,Shaine Reilly | ||
Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez ,Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez ,Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez | ||
Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez ,Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez ,Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez | ||
Karleigh,Destiny,Dean,[email protected],Stockholms län,Märsta,9038,Shaine Reilly,Karleigh,Destiny,Dean,[email protected],Stockholms län,Märsta,9038,Shaine Reilly,Karleigh,Destiny,Dean,[email protected],Stockholms län,Märsta,9038,Shaine Reilly | ||
Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez ,Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez ,Alisa,Walker,Armand,[email protected],Himachal Pradesh,Shimla,MZ0 4QS,Olivia Velez | ||
` | ||
|
||
a := newAlign(strings.NewReader(input), os.Stdout, comma, TextQualifier{On: false}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters