From e8983797072b47580fb7414dce0fe99e670e7664 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Mon, 26 Feb 2024 14:22:33 -0500 Subject: [PATCH] Add testcommon.CompareHex --- testcommon/common.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/testcommon/common.go b/testcommon/common.go index 591d853..0b05ee5 100644 --- a/testcommon/common.go +++ b/testcommon/common.go @@ -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) +}