MCPcopy Index your code
hub / github.com/php/frankenphp / TestSplitPos

Function TestSplitPos

cgi_test.go:36–246  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34}
35
36func TestSplitPos(t *testing.T) {
37 tests := []struct {
38 name string
39 path string
40 splitPath []string
41 wantPos int
42 }{
43 {
44 name: "simple php extension",
45 path: "/path/to/script.php",
46 splitPath: []string{".php"},
47 wantPos: 19,
48 },
49 {
50 name: "php extension with path info",
51 path: "/path/to/script.php/some/path",
52 splitPath: []string{".php"},
53 wantPos: 19,
54 },
55 {
56 name: "case insensitive match",
57 path: "/path/to/script.PHP",
58 splitPath: []string{".php"},
59 wantPos: 19,
60 },
61 {
62 name: "mixed case match",
63 path: "/path/to/script.PhP/info",
64 splitPath: []string{".php"},
65 wantPos: 19,
66 },
67 {
68 name: "no match",
69 path: "/path/to/script.txt",
70 splitPath: []string{".php"},
71 wantPos: -1,
72 },
73 {
74 name: "empty split path",
75 path: "/path/to/script.php",
76 splitPath: []string{},
77 wantPos: 0,
78 },
79 {
80 name: "multiple split paths first match",
81 path: "/path/to/script.php",
82 splitPath: []string{".php", ".phtml"},
83 wantPos: 19,
84 },
85 {
86 name: "multiple split paths second match",
87 path: "/path/to/script.phtml",
88 splitPath: []string{".php", ".phtml"},
89 wantPos: 21,
90 },
91 // Unicode case-folding tests (security fix for GHSA-g966-83w7-6w38)
92 // U+023A (Ⱥ) lowercases to U+2C65 (ⱥ), which has different UTF-8 byte length
93 // Ⱥ: 2 bytes (C8 BA), ⱥ: 3 bytes (E2 B1 A5)

Callers

nothing calls this directly

Calls 1

splitPosFunction · 0.85

Tested by

no test coverage detected