@@ -20,7 +20,8 @@ import (
2020 "testing"
2121
2222 "github.com/sqlc-dev/marino/charset"
23- "github.com/stretchr/testify/require"
23+
24+ "reflect"
2425)
2526
2627func TestNodeSetText (t * testing.T ) {
@@ -37,8 +38,12 @@ func TestNodeSetText(t *testing.T) {
3738 }
3839 for _ , tt := range tests {
3940 n .SetText (tt .enc , tt .text )
40- require .Equal (t , tt .expectUTF8Text , n .Text ())
41- require .Equal (t , tt .expectText , n .OriginalText ())
41+ if ! reflect .DeepEqual (tt .expectUTF8Text , n .Text ()) {
42+ t .Fatalf ("got %v, want %v" , n .Text (), tt .expectUTF8Text )
43+ }
44+ if ! reflect .DeepEqual (tt .expectText , n .OriginalText ()) {
45+ t .Fatalf ("got %v, want %v" , n .OriginalText (), tt .expectText )
46+ }
4247 }
4348}
4449
@@ -66,7 +71,9 @@ func TestBinaryStringLiteralConversion(t *testing.T) {
6671 }
6772 for _ , tt := range printableTests {
6873 n .SetText (charset .EncodingUTF8Impl , tt .text )
69- require .Equal (t , tt .want , n .Text (), tt .name )
74+ if ! reflect .DeepEqual (tt .want , n .Text ()) {
75+ t .Fatalf ("%v: got %v, want %v" , tt .name , n .Text (), tt .want )
76+ }
7077 }
7178
7279 // Binary (non-printable) strings — should convert to 0x hex literals
@@ -98,7 +105,9 @@ func TestBinaryStringLiteralConversion(t *testing.T) {
98105 }
99106 for _ , tt := range binaryTests {
100107 n .SetText (charset .EncodingUTF8Impl , tt .text )
101- require .Equal (t , tt .want , n .Text (), tt .name )
108+ if ! reflect .DeepEqual (tt .want , n .Text ()) {
109+ t .Fatalf ("%v: got %v, want %v" , tt .name , n .Text (), tt .want )
110+ }
102111 }
103112}
104113
@@ -206,7 +215,9 @@ func TestBinaryStringLiteralSkipsComments(t *testing.T) {
206215 }
207216 for _ , tt := range tests {
208217 n .SetText (charset .EncodingUTF8Impl , tt .text )
209- require .Equal (t , tt .want , n .Text (), tt .name )
218+ if ! reflect .DeepEqual (tt .want , n .Text ()) {
219+ t .Fatalf ("%v: got %v, want %v" , tt .name , n .Text (), tt .want )
220+ }
210221 }
211222}
212223
@@ -215,15 +226,21 @@ func TestBinaryStringLiteralNoBackslashEscapes(t *testing.T) {
215226
216227 n .SetText (charset .EncodingUTF8Impl , "SELECT '\\ n'" )
217228 n .SetNoBackslashEscapes (true )
218- require .Equal (t , "SELECT '\\ n'" , n .Text (), "NO_BACKSLASH_ESCAPES literal \\ n" )
229+ if ! reflect .DeepEqual ("SELECT '\\ n'" , n .Text ()) {
230+ t .Fatalf ("%v: got %v, want %v" , "NO_BACKSLASH_ESCAPES literal \\ n" , n .Text (), "SELECT '\\ n'" )
231+ }
219232
220233 n .SetText (charset .EncodingUTF8Impl , "SELECT '\\ ' , 'after'" )
221234 n .SetNoBackslashEscapes (true )
222- require .Equal (t , "SELECT '\\ ' , 'after'" , n .Text (), "NO_BACKSLASH_ESCAPES quote boundary" )
235+ if ! reflect .DeepEqual ("SELECT '\\ ' , 'after'" , n .Text ()) {
236+ t .Fatalf ("%v: got %v, want %v" , "NO_BACKSLASH_ESCAPES quote boundary" , n .Text (), "SELECT '\\ ' , 'after'" )
237+ }
223238
224239 n .SetText (charset .EncodingUTF8Impl , "SELECT '\xd2 \xe4 '" )
225240 n .SetNoBackslashEscapes (true )
226- require .Equal (t , "SELECT 0xd2e4" , n .Text (), "NO_BACKSLASH_ESCAPES binary" )
241+ if ! reflect .DeepEqual ("SELECT 0xd2e4" , n .Text ()) {
242+ t .Fatalf ("%v: got %v, want %v" , "NO_BACKSLASH_ESCAPES binary" , n .Text (), "SELECT 0xd2e4" )
243+ }
227244}
228245
229246func TestBinaryStringLiteralGBK (t * testing.T ) {
@@ -233,23 +250,33 @@ func TestBinaryStringLiteralGBK(t *testing.T) {
233250 // This should be decoded as valid GBK and left as a printable string,
234251 // not converted to a hex literal.
235252 n .SetText (charset .EncodingGBKImpl , "select '\xb1 \xed \x31 '" )
236- require .Equal (t , "select '表1'" , n .Text (), "GBK printable" )
253+ if ! reflect .DeepEqual ("select '表1'" , n .Text ()) {
254+ t .Fatalf ("%v: got %v, want %v" , "GBK printable" , n .Text (), "select '表1'" )
255+ }
237256
238257 // GBK with actual invalid bytes should still convert to hex
239258 n .SetText (charset .EncodingGBKImpl , "select '\x80 \xff '" )
240- require .Equal (t , "select 0x80ff" , n .Text (), "GBK binary" )
259+ if ! reflect .DeepEqual ("select 0x80ff" , n .Text ()) {
260+ t .Fatalf ("%v: got %v, want %v" , "GBK binary" , n .Text (), "select 0x80ff" )
261+ }
241262
242263 // 筡 = \xb9\x5c in GBK; trail byte 0x5c must not be mistaken for backslash
243264 n .SetText (charset .EncodingGBKImpl , "select '\xb9 \x5c '" )
244- require .Equal (t , "select '筡'" , n .Text (), "GBK 0x5c trail byte" )
265+ if ! reflect .DeepEqual ("select '筡'" , n .Text ()) {
266+ t .Fatalf ("%v: got %v, want %v" , "GBK 0x5c trail byte" , n .Text (), "select '筡'" )
267+ }
245268
246269 // Multiple GBK chars with 0x5c trail bytes: 筡 = \xb9\x5c, 臷 = \xc5\x5c
247270 n .SetText (charset .EncodingGBKImpl , "select '\xb9 \x5c \xc5 \x5c '" )
248- require .Equal (t , "select '筡臷'" , n .Text (), "GBK multiple 0x5c trail bytes" )
271+ if ! reflect .DeepEqual ("select '筡臷'" , n .Text ()) {
272+ t .Fatalf ("%v: got %v, want %v" , "GBK multiple 0x5c trail bytes" , n .Text (), "select '筡臷'" )
273+ }
249274
250275 // 0x5c trail byte right before closing quote must not escape the quote
251276 n .SetText (charset .EncodingGBKImpl , "select '\xb9 \x5c ', 'after'" )
252- require .Equal (t , "select '筡', 'after'" , n .Text (), "GBK 0x5c before quote" )
277+ if ! reflect .DeepEqual ("select '筡', 'after'" , n .Text ()) {
278+ t .Fatalf ("%v: got %v, want %v" , "GBK 0x5c before quote" , n .Text (), "select '筡', 'after'" )
279+ }
253280}
254281
255282func buildBinaryClause () string {
0 commit comments