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

Function TestHeaderGenerator_CompleteStructure

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

Source from the content-addressed store, hash-verified

137}
138
139func TestHeaderGenerator_CompleteStructure(t *testing.T) {
140 generator := &Generator{BaseName: "complete_test"}
141 headerGen := HeaderGenerator{generator}
142 content, err := headerGen.buildContent()
143 require.NoError(t, err)
144
145 lines := strings.Split(content, "\n")
146
147 assert.GreaterOrEqual(t, len(lines), 5, "Header file should have multiple lines")
148
149 var foundIfndef, foundDefine, foundEndif bool
150
151 for _, line := range lines {
152 line = strings.TrimSpace(line)
153 if line == "" {
154 continue
155 }
156
157 if strings.HasPrefix(line, "#ifndef") && !foundIfndef {
158 foundIfndef = true
159 } else if strings.HasPrefix(line, "#define") && foundIfndef && !foundDefine {
160 foundDefine = true
161 } else if line == "#endif" {
162 foundEndif = true
163 }
164 }
165
166 assert.True(t, foundIfndef, "Header should start with #ifndef guard")
167 assert.True(t, foundDefine, "Header should have #define after #ifndef")
168 assert.True(t, foundEndif, "Header should end with #endif")
169}
170
171func TestHeaderGenerator_ErrorHandling(t *testing.T) {
172 generator := &Generator{

Callers

nothing calls this directly

Calls 1

buildContentMethod · 0.95

Tested by

no test coverage detected