buffer blocks while no changes underlying, test buffer

This commit is contained in:
Bel LaPointe
2023-03-02 15:17:01 -07:00
parent bfdab392a0
commit 5c5a371f55
3 changed files with 39 additions and 1 deletions

View File

@@ -17,13 +17,33 @@ func TestNew(t *testing.T) {
}
}
func TestNewBuffered(t *testing.T) {
os.Setenv("INPUT_BUFFERED", "true")
t.Cleanup(func() {
os.Unsetenv("INPUT_BUFFERED")
})
r := input.New()
for i := 0; i < 15; i++ {
batch := r.Read()
for j := range batch {
t.Logf("[%d][%d] %c|%v", i, j, batch[j].Char, batch[j].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)
t.Cleanup(func() {
os.Unsetenv("INPUT_RANDOM_WEIGHT_FILE")
})
r := input.New()
for i := 0; i < 15; i++ {
batch := r.Read()