go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/projects/kana-server/pkg/kana/main_test.go (about)

     1  /*
     2  
     3  Copyright (c) 2023 - Present. Will Charczuk. All rights reserved.
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository.
     5  
     6  */
     7  
     8  package kana_test
     9  
    10  import (
    11  	"fmt"
    12  
    13  	"go.charczuk.com/projects/kana-server/pkg/kana"
    14  )
    15  
    16  // GenerateKeyValues generates N key value pairs.
    17  func GenerateKeyValues(n int) map[string]string {
    18  	output := make(map[string]string)
    19  	var xs string
    20  	for x := 0; x < n; x++ {
    21  		xs = fmt.Sprint(x)
    22  		output["k"+xs] = "v" + xs
    23  	}
    24  	return output
    25  }
    26  
    27  // GenerateKeyWeightsDefault generates N uniform key weights.
    28  func GenerateKeyWeightsDefault(n int) map[string]float64 {
    29  	output := make(map[string]float64)
    30  	var xs string
    31  	for x := 0; x < n; x++ {
    32  		xs = fmt.Sprint(x)
    33  		output["k"+xs] = kana.WeightDefault
    34  	}
    35  	return output
    36  }
    37  
    38  // GenerateKeyWeightsIncreasing generates N uniform key weights.
    39  func GenerateKeyWeightsIncreasing(n int) map[string]float64 {
    40  	output := make(map[string]float64)
    41  	var xs string
    42  	for x := 0; x < n; x++ {
    43  		xs = fmt.Sprint(x)
    44  		output["k"+xs] = kana.WeightDefault
    45  	}
    46  	for x := 0; x < n; x++ {
    47  		xs = fmt.Sprint(x)
    48  		for y := 0; y < x; y++ {
    49  			kana.IncreaseWeight(output, "k"+xs)
    50  		}
    51  	}
    52  	return output
    53  }