<commit_before>package main
import (
	"testing"
	"encoding/json"
	"bytes"
	"fmt"
)

type QueryEsearch struct {
	Sort   interface{} `json:"sort"`
	Fields []string `json:"fields"`
}

func TestJson(t *testing.T) {
	arr := QueryEsearch{Sort: []string{"issued", "fake"}, Fields: []string{"123", "321"}}
	jsonb, _ := json.Marshal(arr)

	ctrl := []byte(`{"sort":["issued","fake"],"fields":["123","321"]}`)
	fmt.Println(string(jsonb))
	fmt.Println(string(ctrl))
	if !bytes.Equal(jsonb, ctrl) {
		t.Error("Json errado: %q", jsonb)
	}
}<commit_msg>mais testes com json<commit_after>package main
import (
	"testing"
	"encoding/json"
	"bytes"
)

type SimpleJson struct {
	Sort   interface{} `json:"sort"`
	Fields []string `json:"fields"`
	Const  string `json:"const"`
}

type ComplexStruct struct {
	Complex []SimpleJson `json:"complex"`
}


func TestMarshalSimpleJson(t *testing.T) {
	arr := SimpleJson{Sort: []string{"issued", "fake"}, Fields: []string{"123", "321"}}
	jsonb, _ := json.Marshal(arr)

	ctrl := []byte(`{"sort":["issued","fake"],"fields":["123","321"],"const":""}`)

	if !bytes.Equal(jsonb, ctrl) {
		t.Error("Jsonb errado: %q", string(jsonb))
		t.Error("ctrl errado: %q", string(ctrl))
	}
}

func TestMarshalComplexJson(t *testing.T) {
	ctrl := []byte(`{"complex":[{"sort":["issued","fake"],"fields":["123","321"],"const":"abc"}]}`)
	arr := ComplexStruct{Complex:[]SimpleJson{SimpleJson{Sort: []string{"issued", "fake"}, Fields:
	[]string{"123", "321"}, Const: "abc"}}}
	jsonb, _ := json.Marshal(arr)

	if !bytes.Equal(jsonb, ctrl) {
		t.Error("Jsonb errado", string(jsonb))
		t.Error("ctrl errado", string(ctrl))
	}

}


func TestUnMarshalComplexJson(t *testing.T) {
	ctrl := []byte(`{"complex":[{"sort":["issued","fake"],"fields":["123","321"],"const":"abc"}]}`)
	arr := ComplexStruct{}
	json.Unmarshal(ctrl, &arr)

	if arr.Complex[0].Fields[0] != "123"{
		t.Error("Jsonb errado", string(arr.Complex[0].Fields[0]))
	}

}
{'fraction_non_alphanumeric': 0.2418266735858848, 'fraction_numerical': 0.02542812662169175, 'mean_word_length': 6.303030303030303, 'pattern_counts': {'":': 13, '<': 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': '731381', 'n_tokens_mistral': 769, 'n_tokens_neox': 702, 'n_words': 131}