test $INPUT_RANDOM_WEIGHT_FILE
This commit is contained in:
36
src/device/input/input_exported_test.go
Normal file
36
src/device/input/input_exported_test.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package input_test
|
||||
|
||||
import (
|
||||
"mayhem-party/src/device/input"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
r := input.New()
|
||||
for i := 0; i < 15; i++ {
|
||||
batch := r.Read()
|
||||
for _, got := range batch {
|
||||
t.Logf("[%d] %c:%v", i, got.Char, got.Down)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewRandomWeightFile(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
p := path.Join(d, "f")
|
||||
if err := os.WriteFile(p, []byte(`{"a":1}`), os.ModePerm); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
os.Setenv("INPUT_RANDOM_WEIGHT_FILE", p)
|
||||
r := input.New()
|
||||
for i := 0; i < 15; i++ {
|
||||
batch := r.Read()
|
||||
for _, got := range batch {
|
||||
if got.Char != 'a' {
|
||||
t.Error(got)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user