MCPcopy Create free account
hub / github.com/php/frankenphp / TestHeaderGenerator_HeaderGuardGeneration

Function TestHeaderGenerator_HeaderGuardGeneration

internal/extgen/hfile_test.go:93–121  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

91}
92
93func TestHeaderGenerator_HeaderGuardGeneration(t *testing.T) {
94 tests := []struct {
95 baseName string
96 expectedGuard string
97 }{
98 {"simple", "_SIMPLE_H"},
99 {"my-extension", "_MY_EXTENSION_H"},
100 {"complex.name", "_COMPLEX_NAME_H"},
101 {"under_score", "_UNDER_SCORE_H"},
102 {"MixedCase", "_MIXEDCASE_H"},
103 {"123numeric", "_123NUMERIC_H"},
104 {"special!@#chars", "_SPECIAL___CHARS_H"},
105 }
106
107 for _, tt := range tests {
108 t.Run(tt.baseName, func(t *testing.T) {
109 generator := &Generator{BaseName: tt.baseName}
110 headerGen := HeaderGenerator{generator}
111 content, err := headerGen.buildContent()
112 require.NoError(t, err)
113
114 expectedIfndef := "#ifndef " + tt.expectedGuard
115 expectedDefine := "#define " + tt.expectedGuard
116
117 assert.Contains(t, content, expectedIfndef, "Expected #ifndef %s, but not found in content", tt.expectedGuard)
118 assert.Contains(t, content, expectedDefine, "Expected #define %s, but not found in content", tt.expectedGuard)
119 })
120 }
121}
122
123func TestHeaderGenerator_BasicStructure(t *testing.T) {
124 generator := &Generator{BaseName: "structtest"}

Callers

nothing calls this directly

Calls 1

buildContentMethod · 0.95

Tested by

no test coverage detected