<commit_before>package tnetstring

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

type tnetstringTest struct {
	val  interface{}
	data string
}

// Stable tests used for benchmarking. These match up with the reference
// implementation's benchmark cases.
var stableTests = []tnetstringTest{
	{map[string]string{}, "0:}"},
	{[]bool(nil), "0:]"},
	{"", "0:,"},
	{map[string][]interface{}{"hello": []interface{}{int64(12345678901), "this", true, nil, "\x00\x00\x00\x00"}}, "51:5:hello,39:11:12345678901#4:this,4:true!0:~4:\x00\x00\x00\x00,]}"},
	{12345, "5:12345#"},
	{"this is cool", "12:this is cool,"},
	{nil, "0:~"},
	{true, "4:true!"},
	{false, "5:false!"},
	{"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", "10:\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00,"},
	{[]interface{}{int64(12345), int64(67890), "xxxxx"}, "24:5:12345#5:67890#5:xxxxx,]"},
}

var tnetstringTests = []tnetstringTest{
	{14, "2:14#"},
	{-1, "2:-1#"},
	{1000000000, "10:1000000000#"},
	{uint(14), "2:14#"},
	{uint(1000000000), "10:1000000000#"},
	{"hello", "5:hello,"},
	{[]int{1, 2, 3}, "12:1:1#1:2#1:3#]"},
	{[...]int{1, 2, 3}, "12:1:1#1:2#1:3#]"},
	{[]string{"ab", "cd", "ef"}, "15:2:ab,2:cd,2:ef,]"},
	// can't test more than one map element due to undefined order
	{map[string]int{"a": 1}, "8:1:a,1:1#}"},
	{struct {
		A int
		B string
	}{1, "hello"}, "20:1:A,1:1#1:B,5:hello,}"},
	{&struct {
		A int<commit_msg>Update benchmark tests<commit_after>package tnetstring

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

type tnetstringTest struct {
	val  interface{}
	data string
}

// Stable tests used for benchmarking. These match up with the reference
// implementation's benchmark cases.
var stableTests = []tnetstringTest{
	{map[string]string{}, "0:}"},
	{[]bool(nil), "0:]"},
	{map[string][]interface{}{"hello": []interface{}{int64(12345678901), "this", true, nil, "\x00\x00\x00\x00"}}, "51:5:hello,39:11:12345678901#4:this,4:true!0:~4:\x00\x00\x00\x00,]}"},
	{12345, "5:12345#"},
	{"this is cool", "12:this is cool,"},
	{"", "0:,"},
	{nil, "0:~"},
	{true, "4:true!"},
	{false, "5:false!"},
	{"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", "10:\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00,"},
	{[]interface{}{int64(12345), int64(67890), "xxxxx"}, "24:5:12345#5:67890#5:xxxxx,]"},
	//{[]float64{0.1, 0.2, 0.3}, "18:3:0.1^3:0.2^3:0.3^]"},
	{
		[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]string{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{"hello-there"}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}},
		"243:238:233:228:223:218:213:208:203:198:193:188:183:178:173:168:163:158:153:148:143:138:133:128:123:118:113:108:103:99:95:91:87:83:79:75:71:67:63:59:55:51:47:43:39:35:31:27:23:19:15:11:hello-there,]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]",
	},
}

var tnetstringTests = []tnetstringTest{
	{14, "2:14#"},
	{-1, "2:-1#"},
	{1000000000, "10:1000000000#"},
	{uint(14), "2:14#"},
	{uint(1000000000), "10:1000000000#"},
	{"hello", "5:hello,"},
	{[]int{1, 2, 3}, "12:1:1#1:2#1:3#]"},
	{[...]int{1, 2, 3}, "12:1:1#1:2#1:3#]"},
	{[]string{"ab", "cd", "ef"}, "15:2:ab,2:cd,2:ef,]"},
	// can't test more than one map element due to undefined order
	{map[string]int{"a": 1}, "8:1:a,1:1#}"},
	{struct {
		A int
		B string
	}{1, "hello"}, "20:1:A,1:1#1:B,5:hello,}"},
	{&struct {
		A int
{'fraction_non_alphanumeric': 0.34245339747444375, 'fraction_numerical': 0.1894167167769092, 'mean_word_length': 6.459641255605381, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 8, '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': '2533193', 'n_tokens_mistral': 1949, 'n_tokens_neox': 1591, 'n_words': 235}