package yu_proto

import (
	"fmt"
	yu_hex "gogs.qqck.cn/s/tools/hex"
	yu_rand "gogs.qqck.cn/s/tools/rand"
	"testing"
)

func TestProtobuf_Set(t *testing.T) {
	j_pro := New()
	j_pro.SetString("111", "21")
	j_pro.SetString("111", "20")
	j_pro.SetString(yu_rand.SEx(16), "99")
	j_pro.SetInt64(2, "3", "2", "6")
	j_pro.SetBool(true, "3", "2", "2")
	j_pro.SetBool(false, "3", "2", "4")
	j_pro.SetFloat64(1.7976931348623157, "3", "2", "6")
	j_pro.SetFloat32(3.4020000001, "3", "2", "1")
	fmt.Println(j_pro.Json())
	fmt.Println(yu_hex.Upper(j_pro.Bytes()))
	j_pro.SetString(yu_rand.SEx(16), "3", "1", 6)
	j_pro.SetFloat64(1.7976931348623157, "3", "1", 2)
	fmt.Println(j_pro.Json())
	fmt.Println(yu_hex.Upper(j_pro.Bytes()))
	j_pro.SetString(yu_rand.SEx(16), "6", "1", "10", 0, "1")
	j_pro.SetString(yu_rand.SEx(16), "6", "1", "10", 0, "2", "3")
	j_pro.SetString(yu_rand.SEx(16), "6", "1", "10", 0, "3", 3, "4")
	j_pro.SetString(yu_rand.SEx(16), "6", "1", "10", 1, "1", "5")
	j_pro.SetString(yu_rand.SEx(16), "6", "1", "10", 1, "2", "6")
	j_pro.SetString(yu_rand.SEx(16), "6", "1", "10", 1, "3", 3, "7")
	fmt.Println(j_pro.Json())
	fmt.Println(yu_hex.Upper(j_pro.Bytes()))

	j_pro.SetString(yu_rand.SEx(16), "6", 0, "1")
	j_pro.SetString(yu_rand.SEx(16), "6", 0, "2", "3")
	j_pro.SetString(yu_rand.SEx(16), "6", 0, "3", 3, "4")
	j_pro.SetString(yu_rand.SEx(16), "6", 1, "1", "5")
	j_pro.SetString(yu_rand.SEx(16), "6", 1, "2", "6")
	j_pro.SetString(yu_rand.SEx(16), "6", 1, "3", 3, "7")
	fmt.Println(j_pro.Json())
	fmt.Println(yu_hex.Upper(j_pro.Bytes()))

	j_pro.SetString(yu_rand.SEx(16), "6", 0, 0, "1")
	j_pro.SetString(yu_rand.SEx(16), "6", 0, 0, "2", "3")
	j_pro.SetString(yu_rand.SEx(16), "6", 0, 0, "3", 3, "4")
	fmt.Println(j_pro.Json())
	fmt.Println(yu_hex.Upper(j_pro.Bytes()))
}
