<commit_before>package zclwrite

import (
	"bytes"
	"testing"

	"github.com/zclconf/go-zcl/zcl"
)

func TestRoundTrip(t *testing.T) {
	tests := []string{
		``,
		`foo = 1`,
		`
foobar = 1
baz    = 1
`,
		`
# this file is awesome

# tossed salads and scrambled eggs
block "thing" {
  foobar = 1 # quite stylish
  baz    = 1
}

# and they all lived happily ever after
`,
	}

	for _, test := range tests {
		t.Run(test, func(t *testing.T) {
			src := []byte(test)
			file, diags := parse(src, "", zcl.Pos{Line: 1, Column: 1})
			if len(diags) != 0 {
				for _, diag := range diags {
					t.Logf(" - %s", diag.Error())
				}
				t.Fatalf("unexpected diagnostics")
			}

			wr := &bytes.Buffer{}
			n, err := file.WriteTo(wr)
			if n != len(test) {
				t.Errorf("wrong number of bytes %d; want %d", n, len(test))
			}
			if err != nil {
				t.Fatalf("error from WriteTo")
			}

			result := wr.Bytes()

			if !bytes.Equal(result, src) {
				t.Errorf("wrong result\nresult:\n%s\ninput\n:%s", result, src)
			}
		})
	}
}<commit_msg>zclwrite: correct silly misplaced colon in round_trip_test<commit_after>package zclwrite

import (
	"bytes"
	"testing"

	"github.com/zclconf/go-zcl/zcl"
)

func TestRoundTrip(t *testing.T) {
	tests := []string{
		``,
		`foo = 1`,
		`
foobar = 1
baz    = 1
`,
		`
# this file is awesome

# tossed salads and scrambled eggs
block "thing" {
  foobar = 1 # quite stylish
  baz    = 1
}

# and they all lived happily ever after
`,
	}

	for _, test := range tests {
		t.Run(test, func(t *testing.T) {
			src := []byte(test)
			file, diags := parse(src, "", zcl.Pos{Line: 1, Column: 1})
			if len(diags) != 0 {
				for _, diag := range diags {
					t.Logf(" - %s", diag.Error())
				}
				t.Fatalf("unexpected diagnostics")
			}

			wr := &bytes.Buffer{}
			n, err := file.WriteTo(wr)
			if n != len(test) {
				t.Errorf("wrong number of bytes %d; want %d", n, len(test))
			}
			if err != nil {
				t.Fatalf("error from WriteTo")
			}

			result := wr.Bytes()

			if !bytes.Equal(result, src) {
				t.Errorf("wrong result\nresult:\n%s\ninput:\n%s", result, src)
			}
		})
	}
}
{'fraction_non_alphanumeric': 0.17422434367541767, 'fraction_numerical': 0.0076372315035799524, 'mean_word_length': 2.696649029982363, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5872037', 'n_tokens_mistral': 977, 'n_tokens_neox': 818, 'n_words': 208}