package otherutils

import (
	"fmt"
	"testing"
)

func TestRandChoiceByWeighted(t *testing.T) {
	items := [][]int64{
		{1, 1000},
		{2, 1000},
		{3, 500},
		{4, 10},
	}

	frequencies := make(map[int64]int64)
	for i := 0; i < 10000; i++ {
		selected, _ := RandChoiceByWeighted(items)
		//fmt.Println(selected)
		frequencies[selected]++
	}

	fmt.Println("Frequencies of selection after 10000 trials:")
	for k, v := range frequencies {
		fmt.Printf("%d: %d\n", k, v)
	}
}

func TestRandOneNum(t *testing.T) {
	for i := 0; i < 10; i++ {
		got, _ := RandInterval(0, 5)
		fmt.Println(got)
	}

}
