main 908d8c0

gen_test.go RawHistoryFolder

1package gen
2
3import (
4	"strings"
5	"testing"
6)
7
8func TestDeclarations(t *testing.T) {
9	h := "/* xkb_fake(void); */\nXKB_EXPORT struct xkb_context *\nxkb_context_new(enum xkb_context_flags flags);"
10	if !declared(h, "xkb_context_new") || declared(h, "xkb_fake") {
11		t.Fatal("incorrect declaration selection")
12	}
13	if declared(h, "xkb_context_unref") {
14		t.Fatal("missing declaration accepted")
15	}
16}
17func TestConstants(t *testing.T) {
18	h := "enum xkb_test { XKB_A = (1 << 2), XKB_B, XKB_C = 0x10 };\n#define XKB_MOD_NAME_SHIFT \"Shift\"\n#define XKB_KEY_dead_acute 0xfe51\n"
19	got := constants(h)
20	for _, want := range []string{"XKB_A = (1 << 2)", "XKB_B = 5", "XKB_C = 0x10", "XKB_MOD_NAME_SHIFT = \"Shift\"", "XKB_KEY_dead_acute = 0xfe51"} {
21		if !strings.Contains(got, want) {
22			t.Fatalf("missing %s in %s", want, got)
23		}
24	}
25}
26
27func TestMethodWhitelist(t *testing.T) {
28	for _, sig := range []string{"func(float64) uint32", "func(bool)", "func(uintptr, ...uintptr) uint32", "func(uint32) float32", "func(uint32) unsafe.Pointer", "func(*int)", "func(uint32) bool"} {
29		if _, err := method("xkb_bad", sig); err == nil {
30			t.Fatalf("accepted %s", sig)
31		}
32	}
33	got, err := method("xkb_ok", "func(uintptr, unsafe.Pointer, int32) uint32")
34	if err != nil {
35		t.Fatal(err)
36	}
37	for _, want := range []string{"purego.Syscall6(f.xkb_ok, a1, uintptr(a2), uintptr(a3), 0, 0, 0)", "return uint32(r)", "a2 unsafe.Pointer"} {
38		if !strings.Contains(got, want) {
39			t.Fatalf("missing %q in %s", want, got)
40		}
41	}
42	if got, _ = method("xkb_seven", "func(uintptr,uint32,uint32,uint32,uint32,uint32,uint32)"); !strings.Contains(got, "purego.Syscall15(") {
43		t.Fatal("seven args must use Syscall15")
44	}
45}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 2

↑↓ moveenter openesc close