package common


import (
	"testing"
	"fmt"
)

func TestIdToCode(t *testing.T) {
	var count uint32 = 9999999

	idMap := make(map[string]bool)
	for i := uint32(0); i < count; i++ {
		code := IdToCode(i)
		idMap[code] = true

		id := CodeToId(code)

		if i != id {
			fmt.Println("aaaaaaaaaaaaaa ", i)
		}

		if len(code) != 6 {
			fmt.Println(" ======== len(code) != 6")
			break
		}
	}

	fmt.Println(len(idMap) == int(count))
}

func TestIdTo8BitCode(t *testing.T) {
	var count uint32 = 9999999

	idMap := make(map[string]bool)
	for i := uint32(0); i < count; i++ {
		code := IdTo8BitCode(i)
		idMap[code] = true

		id := Code8ToId(code)

		if i != id {
			fmt.Println("xxxxxxxxxxxxxxx ", i)
		}

		if len(code) != 8 {
			fmt.Println(" ............. len(code) != 8", i)
			break
		}
	}

	fmt.Println(len(idMap) == int(count))
}