<commit_before>package sudoku

import (
	"encoding/json"
	"reflect"
	"testing"
)

var jsonData = []byte(`
  {
    "ConfigJson" : {
      "Edge":2
    },
    "TerminalJson": [
      {
        "RowJson":[
          {
            "ColumnJson":[
              {
                "Digit":1,
                "Block":1
              }
            ]
          },
          {
            "ColumnJson":[
              {
                "Digit":2,
                "Block":2
              }
            ]
          }
        ]
      },
      {
        "RowJson":[
          {
            "ColumnJson":[
              {
                "Digit":2,
                "Block":1
              }
            ]
          },
          {
            "ColumnJson":[
              {
                "Digit":1,
                "Block":2
              }
            ]
          }
        ]
      }
    ]
  }
`)

func Test_PuzzleJson_from_jsonData(t *testing.T) {
	var puzzleJson PuzzleJson
	err := json.Unmarshal(jsonData, &puzzleJson)
	if err != nil {
		t.Error("Invalid json data:\n%v", jsonData)
	}
	if puzzleJson.Config.Edge != 2 {
		t.Error("Config.Edge should be 2")
	}
	if len(puzzleJson.Terminal) != 2 {
		t.Error("len(puzzleJson.Terminal) should be 2")
	}
	if len(puzzleJson.Terminal[1].Row) != 2 {
		t.Error("len(puzzleJson.Terminal[1].Row) should be 2")
	}
	if len(puzzleJson.Terminal[1].Row[1].Column) != 1 {
		t.Error("len(puzzleJson.Terminal[1].Row[1].Column) should be 1")
	}
	if puzzleJson.Terminal[1].Row[1].Column[0].Digit != 1 {
		t.Error("Terminal[1].Row[1].Column[0].Digit should be 1")
	}
	if puzzleJson.Terminal[1].Row[1].Column[0].Block != 2 {
		t.Error("Terminal[1].Row[1].Column[0].Digit should be 2")
	}
}

func Test_PuzzleJson_to_jsonData(t *testing.T) {
	var puzzleJson PuzzleJson
	json.Unmarshal(jsonData, &puzzleJson)
	jsonData2, _ := json.Marshal(puzzleJson)
	var puzzleJson2 PuzzleJson
	json.Unmarshal(jsonData2, &puzzleJson2)

	if !reflect.DeepEqual(puzzleJson2, puzzleJson) {
		t.Error("reflect.DeepEqual(puzzleJson2, puzzleJson) should be true")
	}
}<commit_msg>rename<commit_after>package sudoku

import (
	"encoding/json"
	"reflect"
	"testing"
)

var jsonRaw = []byte(`
  {
    "ConfigJson" : {
      "Edge":2
    },
    "TerminalJson": [
      {
        "RowJson":[
          {
            "ColumnJson":[
              {
                "Digit":1,
                "Block":1
              }
            ]
          },
          {
            "ColumnJson":[
              {
                "Digit":2,
                "Block":2
              }
            ]
          }
        ]
      },
      {
        "RowJson":[
          {
            "ColumnJson":[
              {
                "Digit":2,
                "Block":1
              }
            ]
          },
          {
            "ColumnJson":[
              {
                "Digit":1,
                "Block":2
              }
            ]
          }
        ]
      }
    ]
  }
`)

func Test_PuzzleJson_from_jsonData(t *testing.T) {
	var puzzleJson PuzzleJson
	err := json.Unmarshal(jsonRaw, &puzzleJson)
	if err != nil {
		t.Error("Invalid json data:\n%v", jsonRaw)
	}
	if puzzleJson.Config.Edge != 2 {
		t.Error("Config.Edge should be 2")
	}
	if len(puzzleJson.Terminal) != 2 {
		t.Error("len(puzzleJson.Terminal) should be 2")
	}
	if len(puzzleJson.Terminal[1].Row) != 2 {
		t.Error("len(puzzleJson.Terminal[1].Row) should be 2")
	}
	if len(puzzleJson.Terminal[1].Row[1].Column) != 1 {
		t.Error("len(puzzleJson.Terminal[1].Row[1].Column) should be 1")
	}
	if puzzleJson.Terminal[1].Row[1].Column[0].Digit != 1 {
		t.Error("Terminal[1].Row[1].Column[0].Digit should be 1")
	}
	if puzzleJson.Terminal[1].Row[1].Column[0].Block != 2 {
		t.Error("Terminal[1].Row[1].Column[0].Digit should be 2")
	}
}

func Test_PuzzleJson_to_jsonData(t *testing.T) {
	var puzzleJson PuzzleJson
	json.Unmarshal(jsonRaw, &puzzleJson)
	jsonData2, _ := json.Marshal(puzzleJson)
	var puzzleJson2 PuzzleJson
	json.Unmarshal(jsonData2, &puzzleJson2)

	if !reflect.DeepEqual(puzzleJson2, puzzleJson) {
		t.Error("reflect.DeepEqual(puzzleJson2, puzzleJson) should be true")
	}
}
{'fraction_non_alphanumeric': 0.15064180188907725, 'fraction_numerical': 0.021797045289416325, 'mean_word_length': 1.697583278902678, 'pattern_counts': {'":': 32, '<': 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': '5972091', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1440, 'n_words': 214}