commit 114678fae14c075ec765088ec284fcc9de7e56c4
parent 875229a3c98b4d1df67aa2fc9bb8acba38ae37f4
Author: Oliver Lowe <o@olowe.co>
Date: Fri, 31 May 2024 18:43:55 +1000
cmcd: Test encoding CMCD structures, too
Since there were no testing of this before. This caught the bug fixed
in the previous commit!
Diffstat:
1 file changed, 11 insertions(+), 0 deletions(-)
diff --git a/cmcd/parse_test.go b/cmcd/parse_test.go
@@ -8,6 +8,7 @@ import (
"os"
"path"
"reflect"
+ "sort"
"strings"
"testing"
"time"
@@ -65,6 +66,16 @@ func TestParse(t *testing.T) {
t.Log(want.Encode())
t.Log(info.Encode())
}
+
+ // now try re-encoding to see if we get the same back again.
+ // trim stray commas used for testing parser.
+ swant := strings.Split(strings.Trim(pt.query, ","), ",")
+ sgot := strings.Split(info.Encode(), ",")
+ sort.Strings(swant)
+ sort.Strings(sgot)
+ if !reflect.DeepEqual(sgot, swant) {
+ t.Errorf("re-encode: got %v, want %v", sgot, swant)
+ }
})
}
}