|
|
@ -5,21 +5,62 @@ import "testing"
|
|
|
|
func Test_getBraketedData(t *testing.T) {
|
|
|
|
func Test_getBraketedData(t *testing.T) {
|
|
|
|
type args struct {
|
|
|
|
type args struct {
|
|
|
|
inputLine string
|
|
|
|
inputLine string
|
|
|
|
braketType string
|
|
|
|
braketType BraketType
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
name string
|
|
|
|
args args
|
|
|
|
args args
|
|
|
|
wantText string
|
|
|
|
wantBraketedData string
|
|
|
|
wantCleanedLine string
|
|
|
|
wantCleanedLine string
|
|
|
|
}{
|
|
|
|
}{
|
|
|
|
// TODO: Add test cases.
|
|
|
|
{
|
|
|
|
|
|
|
|
"Happy case: comment",
|
|
|
|
|
|
|
|
args{ inputLine: "aaaa <bracketed text> bbbbb", braketType: COMMENT},
|
|
|
|
|
|
|
|
"bracketed text",
|
|
|
|
|
|
|
|
"aaaa bbbbb",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"Happy case: QSL",
|
|
|
|
|
|
|
|
args{ inputLine: "aaaa [bracketed text] bbbbb", braketType: QSL},
|
|
|
|
|
|
|
|
"bracketed text",
|
|
|
|
|
|
|
|
"aaaa bbbbb",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"Happy case: nothing",
|
|
|
|
|
|
|
|
args{ inputLine: "aaaa bbbbb cccccc", braketType: QSL},
|
|
|
|
|
|
|
|
"",
|
|
|
|
|
|
|
|
"aaaa bbbbb cccccc",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"Empty brackets",
|
|
|
|
|
|
|
|
args{ inputLine: "aaaa <> bbbbb", braketType: COMMENT},
|
|
|
|
|
|
|
|
"",
|
|
|
|
|
|
|
|
"aaaa bbbbb",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"Brackets at right",
|
|
|
|
|
|
|
|
args{ inputLine: "aaaa bbbbb <bracketed text>", braketType: COMMENT},
|
|
|
|
|
|
|
|
"bracketed text",
|
|
|
|
|
|
|
|
"aaaa bbbbb ",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"concatenated",
|
|
|
|
|
|
|
|
args{ inputLine: "aaaa<bracketed text>bbbbb", braketType: COMMENT},
|
|
|
|
|
|
|
|
"bracketed text",
|
|
|
|
|
|
|
|
"aaaabbbbb",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"duplicated",
|
|
|
|
|
|
|
|
args{ inputLine: "aaaa <bracketed text> bbbbb < double > cccc", braketType: COMMENT},
|
|
|
|
|
|
|
|
"bracketed text",
|
|
|
|
|
|
|
|
"aaaa bbbbb < double > cccc",
|
|
|
|
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
gotText, gotCleanedLine := getBraketedData(tt.args.inputLine, tt.args.braketType)
|
|
|
|
gotBraketedData, gotCleanedLine := getBraketedData(tt.args.inputLine, tt.args.braketType)
|
|
|
|
if gotText != tt.wantText {
|
|
|
|
if gotBraketedData != tt.wantBraketedData {
|
|
|
|
t.Errorf("getBraketedData() gotText = %v, want %v", gotText, tt.wantText)
|
|
|
|
t.Errorf("getBraketedData() gotBraketedData = %v, want %v", gotBraketedData, tt.wantBraketedData)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if gotCleanedLine != tt.wantCleanedLine {
|
|
|
|
if gotCleanedLine != tt.wantCleanedLine {
|
|
|
|
t.Errorf("getBraketedData() gotCleanedLine = %v, want %v", gotCleanedLine, tt.wantCleanedLine)
|
|
|
|
t.Errorf("getBraketedData() gotCleanedLine = %v, want %v", gotCleanedLine, tt.wantCleanedLine)
|
|
|
|