|
@@ -7,6 +7,7 @@ import (
|
|
|
"log"
|
|
|
"net"
|
|
|
"os"
|
|
|
+ "strings"
|
|
|
"testing"
|
|
|
"time"
|
|
|
)
|
|
@@ -18,7 +19,7 @@ import (
|
|
|
// go test -c; ./door.test -test.run DoorCP437 -test.v
|
|
|
|
|
|
const KEEP_LOGS bool = false
|
|
|
-const VERBOSE_TEST bool = true // false
|
|
|
+const VERBOSE_TEST bool = false
|
|
|
|
|
|
func TestGoto(t *testing.T) {
|
|
|
GotoMap := map[string][]int{"\x1b[10;20H": {20, 10},
|
|
@@ -260,6 +261,20 @@ func InputTests(t *testing.T, server net.Conn, d *Door, mode string) {
|
|
|
"\U0001f920\u2615": []rune{'\U0001f920', '\u2615'},
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ Test input buffer processing.
|
|
|
+ Create a string with unicode that doesn't fit into the
|
|
|
+ entire read buffer. And build the proper response to match.
|
|
|
+ */
|
|
|
+
|
|
|
+ // x = number of missing bytes (from unicode symbol).
|
|
|
+ for x := 1; x <= 3; x++ {
|
|
|
+ tosend := strings.Repeat(" ", READ_SIZE-x) + "\U0001f920"
|
|
|
+ receive := []rune(strings.Repeat(" ", READ_SIZE-x))
|
|
|
+ receive = append(receive, '\U0001f920')
|
|
|
+ keytest[tosend] = receive
|
|
|
+ }
|
|
|
+
|
|
|
keyextest := map[string][]Extended{
|
|
|
"\x00\x50\x00\x48\x00\x4b\x00\x4d": []Extended{DOWN_ARROW, UP_ARROW, LEFT_ARROW, RIGHT_ARROW},
|
|
|
"\x00\x47\x00\x4f\x00\x49\x00\x51": []Extended{HOME, END, PAGE_UP, PAGE_DOWN},
|
|
@@ -328,7 +343,7 @@ func InputTests(t *testing.T, server net.Conn, d *Door, mode string) {
|
|
|
}
|
|
|
|
|
|
if len(recv) != len(get) {
|
|
|
- t.Errorf("Sent %#v, LEN expected %#v, got %#v", send, get, recv)
|
|
|
+ t.Errorf("FAILURE: Sent %#v, LEN expected %#v, got %#v", send, get, recv)
|
|
|
} else {
|
|
|
matches := true
|
|
|
for idx, i := range get {
|
|
@@ -338,7 +353,11 @@ func InputTests(t *testing.T, server net.Conn, d *Door, mode string) {
|
|
|
}
|
|
|
}
|
|
|
if !matches {
|
|
|
- t.Errorf("Sent %#v, MATCH expected %#v, got %#v", send, get, recv)
|
|
|
+ t.Errorf("FAILURE: Sent %#v, MATCH expected %#v, got %#v", send, get, recv)
|
|
|
+ } else {
|
|
|
+ if VERBOSE_TEST {
|
|
|
+ t.Logf("Success.")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|