-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(filter): properly handle options with ansi styles (#789)
* fix(filter): handle styles option matches * perf: use ranges * fix: cut * fix: ansi update
- Loading branch information
Showing
5 changed files
with
112 additions
and
29 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package filter | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestMatchedRanges(t *testing.T) { | ||
for name, tt := range map[string]struct { | ||
in []int | ||
out [][2]int | ||
}{ | ||
"empty": { | ||
in: []int{}, | ||
out: [][2]int{}, | ||
}, | ||
"one char": { | ||
in: []int{1}, | ||
out: [][2]int{{1, 1}}, | ||
}, | ||
"2 char range": { | ||
in: []int{1, 2}, | ||
out: [][2]int{{1, 2}}, | ||
}, | ||
"multiple char range": { | ||
in: []int{1, 2, 3, 4, 5, 6}, | ||
out: [][2]int{{1, 6}}, | ||
}, | ||
"multiple char ranges": { | ||
in: []int{1, 2, 3, 5, 6, 10, 11, 12, 13, 23, 24, 40, 42, 43, 45, 52}, | ||
out: [][2]int{{1, 3}, {5, 6}, {10, 13}, {23, 24}, {40, 40}, {42, 43}, {45, 45}, {52, 52}}, | ||
}, | ||
} { | ||
t.Run(name, func(t *testing.T) { | ||
match := matchedRanges(tt.in) | ||
if !reflect.DeepEqual(match, tt.out) { | ||
t.Errorf("expected %v, got %v", tt.out, match) | ||
} | ||
}) | ||
} | ||
} |
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