Add testcommon.CompareHex

This commit is contained in:
Sasha Koshka 2024-02-26 14:22:33 -05:00
parent dc47a4c8c0
commit e898379707
1 changed files with 8 additions and 1 deletions

View File

@ -4,6 +4,7 @@ package testcommon
import "testing"
import "strings"
import "strconv"
import "encoding/hex"
// LogColumns logs columns of text side by side, each column 80 characters wide.
func LogColumns (test *testing.T, width int, columns ...any) {
@ -52,6 +53,12 @@ func Compare (test *testing.T, correct, got string) {
} else {
LogColumns(test, width, left, right)
}
}
}
// CompareHex is like compare, but it prits out the differences in
func CompareHex (test *testing.T, correct, got string) {
correct = hex.Dump([]byte(correct))
got = hex.Dump([]byte(got))
Compare(test, correct, got)
}