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

Function testHeaderBasicStructure

internal/extgen/hfile_test.go:276–297  ·  view source on GitHub ↗
(t *testing.T, content, baseName string)

Source from the content-addressed store, hash-verified

274}
275
276func testHeaderBasicStructure(t *testing.T, content, baseName string) {
277 headerGuard := strings.Map(func(r rune) rune {
278 if r >= 'A' && r <= 'Z' || r >= 'a' && r <= 'z' || r >= '0' && r <= '9' {
279 return r
280 }
281
282 return '_'
283 }, baseName)
284 headerGuard = strings.ToUpper(headerGuard) + "_H"
285
286 requiredElements := []string{
287 "#ifndef _" + headerGuard,
288 "#define _" + headerGuard,
289 "#include <php.h>",
290 "extern zend_module_entry test_extension_module_entry;",
291 "#endif",
292 }
293
294 for _, element := range requiredElements {
295 assert.Contains(t, content, element, "Header file should contain: %s", element)
296 }
297}
298
299func testHeaderIncludeGuards(t *testing.T, content, expectedGuard string) {
300 expectedIfndef := "#ifndef _" + expectedGuard

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected