1
0
Fork 0
mirror of https://github.com/on4kjm/FLEcli.git synced 2025-02-07 16:32:46 +01:00
FLEcli/fleprocess/braketedData_test.go

87 lines
2.3 KiB
Go
Raw Normal View History

2020-07-29 08:22:13 +02:00
package fleprocess
2020-06-11 14:00:54 +02:00
import "testing"
2020-08-09 16:15:40 +02:00
/*
Copyright © 2020 Jean-Marc Meessen, ON4KJM <on4kjm@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
2020-06-11 14:00:54 +02:00
func Test_getBraketedData(t *testing.T) {
type args struct {
inputLine string
2020-06-11 21:56:38 +02:00
braketType BraketType
2020-06-11 14:00:54 +02:00
}
tests := []struct {
2020-06-11 21:56:38 +02:00
name string
args args
wantBraketedData string
wantCleanedLine string
2020-06-11 14:00:54 +02:00
}{
2020-06-11 21:56:38 +02:00
{
2020-06-25 21:05:54 +02:00
"Happy case: comment",
args{inputLine: "aaaa <bracketed text> bbbbb", braketType: COMMENT},
"bracketed text",
2020-06-11 21:56:38 +02:00
"aaaa bbbbb",
},
{
2020-06-25 21:05:54 +02:00
"Happy case: QSL",
args{inputLine: "aaaa [bracketed text] bbbbb", braketType: QSL},
"bracketed text",
2020-06-11 21:56:38 +02:00
"aaaa bbbbb",
},
{
2020-06-25 21:05:54 +02:00
"Happy case: nothing",
args{inputLine: "aaaa bbbbb cccccc", braketType: QSL},
"",
2020-06-11 21:56:38 +02:00
"aaaa bbbbb cccccc",
},
{
2020-06-25 21:05:54 +02:00
"Empty brackets",
args{inputLine: "aaaa <> bbbbb", braketType: COMMENT},
"",
2020-06-11 21:56:38 +02:00
"aaaa bbbbb",
},
{
2020-06-25 21:05:54 +02:00
"Brackets at right",
args{inputLine: "aaaa bbbbb <bracketed text>", braketType: COMMENT},
"bracketed text",
2020-06-11 21:56:38 +02:00
"aaaa bbbbb ",
},
{
2020-06-25 21:05:54 +02:00
"concatenated",
args{inputLine: "aaaa<bracketed text>bbbbb", braketType: COMMENT},
"bracketed text",
2020-06-11 21:56:38 +02:00
"aaaabbbbb",
},
{
2020-06-25 21:05:54 +02:00
"duplicated",
args{inputLine: "aaaa <bracketed text> bbbbb < double > cccc", braketType: COMMENT},
"bracketed text",
2020-06-11 21:56:38 +02:00
"aaaa bbbbb < double > cccc",
},
2020-06-11 14:00:54 +02:00
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
2020-06-11 21:56:38 +02:00
gotBraketedData, gotCleanedLine := getBraketedData(tt.args.inputLine, tt.args.braketType)
if gotBraketedData != tt.wantBraketedData {
t.Errorf("getBraketedData() gotBraketedData = %v, want %v", gotBraketedData, tt.wantBraketedData)
2020-06-11 14:00:54 +02:00
}
if gotCleanedLine != tt.wantCleanedLine {
t.Errorf("getBraketedData() gotCleanedLine = %v, want %v", gotCleanedLine, tt.wantCleanedLine)
}
})
}
}