v0.31.0 bf0756b

accent_test.go RawHistoryFolder

1package entity
2
3import (
4	"testing"
5)
6
7func TestHasAccents(t *testing.T) {
8	tests := []struct {
9		name string
10		char rune
11		want bool
12	}{
13		{"lowercase e", 'e', true},
14		{"uppercase E", 'E', true},
15		{"lowercase a", 'a', true},
16		{"uppercase A", 'A', true},
17		{"lowercase c", 'c', true},
18		{"lowercase n", 'n', true},
19		{"lowercase x (no accents)", 'x', false},
20		{"uppercase X (no accents)", 'X', false},
21		{"digit 1 (no accents)", '1', false},
22		{"space (no accents)", ' ', false},
23	}
24
25	for _, tt := range tests {
26		t.Run(tt.name, func(t *testing.T) {
27			got := HasAccents(tt.char)
28			if got != tt.want {
29				t.Errorf("HasAccents(%q) = %v, want %v", tt.char, got, tt.want)
30			}
31		})
32	}
33}
34
35func TestGetAccents(t *testing.T) {
36	tests := []struct {
37		name      string
38		char      rune
39		uppercase bool
40		wantLen   int
41		wantFirst rune
42	}{
43		{"lowercase e", 'e', false, 6, 'è'},
44		{"uppercase E", 'E', true, 6, 'È'},
45		{"lowercase a", 'a', false, 7, 'à'},
46		{"uppercase A", 'A', true, 7, 'À'},
47		{"lowercase c", 'c', false, 3, 'ç'},
48		{"uppercase C with shift", 'c', true, 3, 'Ç'},
49		{"no accents x", 'x', false, 0, 0},
50	}
51
52	for _, tt := range tests {
53		t.Run(tt.name, func(t *testing.T) {
54			got := GetAccents(tt.char, tt.uppercase)
55
56			if len(got) != tt.wantLen {
57				t.Errorf("GetAccents(%q, %v) length = %d, want %d", tt.char, tt.uppercase, len(got), tt.wantLen)
58			}
59
60			if tt.wantLen > 0 && got[0] != tt.wantFirst {
61				t.Errorf("GetAccents(%q, %v)[0] = %q, want %q", tt.char, tt.uppercase, got[0], tt.wantFirst)
62			}
63		})
64	}
65}
66
67func TestGetAccents_UppercaseFromLowercase(t *testing.T) {
68	// When passing lowercase char with uppercase=true, should return uppercase accents
69	uppercase := GetAccents('e', true)
70	lowercase := GetAccents('e', false)
71
72	if len(uppercase) == 0 {
73		t.Fatal("expected accents for 'e' with uppercase=true")
74	}
75
76	if len(uppercase) != len(lowercase) {
77		t.Fatalf("uppercase and lowercase accent counts differ: %d vs %d", len(uppercase), len(lowercase))
78	}
79
80	// Verify each uppercase accent is different from the corresponding lowercase accent
81	for i, upper := range uppercase {
82		lower := lowercase[i]
83		if upper == lower {
84			t.Errorf("accent at index %d is same for uppercase and lowercase: %q", i, upper)
85		}
86	}
87
88	// Verify first accent is È (uppercase of è)
89	if uppercase[0] != 'È' {
90		t.Errorf("expected first uppercase accent to be È, got %q", uppercase[0])
91	}
92}
93
94func TestAccentMapCoverage(t *testing.T) {
95	// Verify all expected characters have accents
96	expectedChars := []rune{'a', 'c', 'e', 'i', 'n', 'o', 's', 'u', 'y'}
97
98	for _, char := range expectedChars {
99		if !HasAccents(char) {
100			t.Errorf("expected %q to have accents", char)
101		}
102
103		accents := GetAccents(char, false)
104		if len(accents) == 0 {
105			t.Errorf("expected %q to have at least one accent variant", char)
106		}
107	}
108}

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 8

Tags 42

↑↓ moveenter openesc close