From cbf8ec9ae3212e9642385c034fe0b0846af6dfd0 Mon Sep 17 00:00:00 2001
From: Luke Shumaker <lukeshu@lukeshu.com>
Date: Fri, 27 Jan 2023 13:12:35 -0700
Subject: BREAKING CHANGE: reencode: Separate config from state

---
 reencode_test.go | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

(limited to 'reencode_test.go')

diff --git a/reencode_test.go b/reencode_test.go
index f4b962f..38f3f8f 100644
--- a/reencode_test.go
+++ b/reencode_test.go
@@ -14,13 +14,13 @@ import (
 func TestReEncode(t *testing.T) {
 	t.Parallel()
 	type testcase struct {
-		enc ReEncoder
+		enc ReEncoderConfig
 		in  any
 		exp string
 	}
 	testcases := map[string]testcase{
 		"basic": {
-			enc: ReEncoder{
+			enc: ReEncoderConfig{
 				Indent:         "\t",
 				CompactIfUnder: 10,
 			},
@@ -36,7 +36,7 @@ func TestReEncode(t *testing.T) {
 }`,
 		},
 		"arrays1": {
-			enc: ReEncoder{
+			enc: ReEncoderConfig{
 				Indent:                "\t",
 				CompactIfUnder:        10,
 				ForceTrailingNewlines: true,
@@ -64,7 +64,7 @@ func TestReEncode(t *testing.T) {
 `,
 		},
 		"arrays2": {
-			enc: ReEncoder{
+			enc: ReEncoderConfig{
 				Indent:                "\t",
 				CompactIfUnder:        10,
 				ForceTrailingNewlines: true,
@@ -92,7 +92,7 @@ func TestReEncode(t *testing.T) {
 `,
 		},
 		"arrays3": {
-			enc: ReEncoder{
+			enc: ReEncoderConfig{
 				Indent:                "\t",
 				ForceTrailingNewlines: true,
 			},
@@ -126,9 +126,7 @@ func TestReEncode(t *testing.T) {
 		t.Run(tcName, func(t *testing.T) {
 			t.Parallel()
 			var out strings.Builder
-			fmter := tc.enc
-			fmter.Out = &out
-			enc := NewEncoder(&fmter)
+			enc := NewEncoder(NewReEncoder(&out, tc.enc))
 			assert.NoError(t, enc.Encode(tc.in))
 			assert.Equal(t, tc.exp, out.String())
 		})
-- 
cgit v1.2.3-2-g168b