Include newline in pager accumulation calc
This commit is contained in:
parent
aa0c2a283f
commit
677dbf536f
@ -3,6 +3,7 @@ package engine
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -12,11 +13,10 @@ import (
|
|||||||
"git.defalsify.org/festive/state"
|
"git.defalsify.org/festive/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLoopCorrect(t *testing.T) {
|
func TestLoopBackForth(t *testing.T) {
|
||||||
generateTestData(t)
|
generateTestData(t)
|
||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
st := state.NewState(0)
|
st := state.NewState(0)
|
||||||
//rs := NewFsWrapper(dataDir, &st)
|
|
||||||
rs := resource.NewFsResource(dataDir)
|
rs := resource.NewFsResource(dataDir)
|
||||||
ca := cache.NewCache().WithCacheSize(1024)
|
ca := cache.NewCache().WithCacheSize(1024)
|
||||||
|
|
||||||
@ -42,3 +42,45 @@ func TestLoopCorrect(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLoopBrowse(t *testing.T) {
|
||||||
|
generateTestData(t)
|
||||||
|
ctx := context.TODO()
|
||||||
|
st := state.NewState(0)
|
||||||
|
rs := resource.NewFsResource(dataDir)
|
||||||
|
ca := cache.NewCache().WithCacheSize(1024)
|
||||||
|
|
||||||
|
cfg := Config{
|
||||||
|
OutputSize: 68,
|
||||||
|
}
|
||||||
|
en := NewEngine(cfg, &st, &rs, ca)
|
||||||
|
err := en.Init("root", ctx)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
input := []string{
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"00",
|
||||||
|
"11",
|
||||||
|
"00",
|
||||||
|
}
|
||||||
|
inputStr := strings.Join(input, "\n")
|
||||||
|
inputBuf := bytes.NewBuffer(append([]byte(inputStr), 0x0a))
|
||||||
|
outputBuf := bytes.NewBuffer(nil)
|
||||||
|
log.Printf("running with input: %s", inputBuf.Bytes())
|
||||||
|
|
||||||
|
err = Loop(&en, "root", ctx, inputBuf, outputBuf)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
location, idx := st.Where()
|
||||||
|
if location != "long" {
|
||||||
|
fmt.Errorf("expected location 'long', got %s", location)
|
||||||
|
}
|
||||||
|
if idx != 1 {
|
||||||
|
fmt.Errorf("expected idx 1, got %v", idx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -230,7 +230,8 @@ func(pg *Page) prepare(sym string, values map[string]string, idx uint16) (map[st
|
|||||||
|
|
||||||
netRemaining := remaining
|
netRemaining := remaining
|
||||||
if len(sinkValues) > 1 {
|
if len(sinkValues) > 1 {
|
||||||
netRemaining -= menuSizes[1]
|
log.Printf("menusizes %v", menuSizes)
|
||||||
|
netRemaining -= menuSizes[1] - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, v := range sinkValues {
|
for i, v := range sinkValues {
|
||||||
@ -253,6 +254,7 @@ func(pg *Page) prepare(sym string, values map[string]string, idx uint16) (map[st
|
|||||||
}
|
}
|
||||||
if tb.Len() > 0 {
|
if tb.Len() > 0 {
|
||||||
tb.WriteByte(byte(0x00))
|
tb.WriteByte(byte(0x00))
|
||||||
|
l += 1
|
||||||
}
|
}
|
||||||
tb.WriteString(v)
|
tb.WriteString(v)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user