<commit_before>package protocol

import "testing"
import "github.com/jennal/goplay/handler/pkg"
import "fmt"

func TestGobDecode(t *testing.T) {
	encoder := GobEncoder{}
	decoder := GobDecoder{}

	content := []int{1, 2, 3}
	pack := pkg.Header{
		Type:        pkg.PKG_NOTIFY,
		Encoding:    pkg.ENCODING_GOB,
		ID:          2,
		ContentSize: len(content),
	}
	buffer := encoder.Marshal(&pack, content)

	newPack := pkg.Header{}
	var newContent []int
	decoder.Unmarshal(buffer, &newPack, &newContent)

	fmt.Println(pack, newPack)
	fmt.Println(content, newContent)

	if pack.Type != newPack.Type {
		t.Errorf("package.Type are not equal %v != %v", pack.Type, newPack.Type)
		t.Fail()
	}

	if pack.Encoding != newPack.Encoding {
		t.Errorf("package.Encoding are not equal %v != %v", pack.Encoding, newPack.Encoding)
		t.Fail()
	}

	if pack.ID != newPack.ID {
		t.Errorf("package.ID are not equal %v != %v", pack.ID, newPack.ID)
		t.Fail()
	}

	if content[0] != newContent[0] {
		t.Errorf("package.Content[0] are not equal %v != %v",
			content[0],
			newContent[0])
		t.Fail()
	}
}

func BenchmarkGobDecode(b *testing.B) {
	encoder := GobEncoder{}
	decoder := GobDecoder{}
	pack := pkg.Header{
		Type:     pkg.PKG_NOTIFY,
		Encoding: pkg.ENCODING_GOB,
		ID:       2,
	}
	content := []int{1, 2, 3, 4}

	buffer := encoder.Marshal(&pack, content)
	newHeader := pkg.Header{}
	var newContent []int
	for i := 0; i < b.N; i++ {
		decoder.Unmarshal(buffer, &newHeader, &newContent)
	}
}
<commit_msg>fix gob_test<commit_after>package protocol

import "testing"
import "github.com/jennal/goplay/handler/pkg"
import "fmt"

func TestGobDecode(t *testing.T) {
	encoder := GobEncoder{}
	decoder := GobDecoder{}

	content := []int{1, 2, 3}
	pack := pkg.Header{
		Type:     pkg.PKG_NOTIFY,
		Encoding: pkg.ENCODING_GOB,
		ID:       2,
	}
	buffer := encoder.Marshal(&pack, content)

	newPack := pkg.Header{}
	var newContent []int
	decoder.Unmarshal(buffer, &newPack, &newContent)

	fmt.Println(pack, newPack)
	fmt.Println(content, newContent)

	if pack.Type != newPack.Type {
		t.Errorf("package.Type are not equal %v != %v", pack.Type, newPack.Type)
		t.Fail()
	}

	if pack.Encoding != newPack.Encoding {
		t.Errorf("package.Encoding are not equal %v != %v", pack.Encoding, newPack.Encoding)
		t.Fail()
	}

	if pack.ID != newPack.ID {
		t.Errorf("package.ID are not equal %v != %v", pack.ID, newPack.ID)
		t.Fail()
	}

	if content[0] != newContent[0] {
		t.Errorf("package.Content[0] are not equal %v != %v",
			content[0],
			newContent[0])
		t.Fail()
	}
}

func BenchmarkGobDecode(b *testing.B) {
	encoder := GobEncoder{}
	decoder := GobDecoder{}
	pack := pkg.Header{
		Type:     pkg.PKG_NOTIFY,
		Encoding: pkg.ENCODING_GOB,
		ID:       2,
	}
	content := []int{1, 2, 3, 4}

	buffer := encoder.Marshal(&pack, content)
	newHeader := pkg.Header{}
	var newContent []int
	for i := 0; i < b.N; i++ {
		decoder.Unmarshal(buffer, &newHeader, &newContent)
	}
}

{'fraction_non_alphanumeric': 0.16695059625212946, 'fraction_numerical': 0.010221465076660987, 'mean_word_length': 3.6677265500794913, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5590368', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1111, 'n_words': 257}