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

Function TestCFileContentValidation

internal/extgen/cfile_test.go:364–401  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

362}
363
364func TestCFileContentValidation(t *testing.T) {
365 generator := &Generator{
366 BaseName: "syntax_test",
367 Functions: []phpFunction{
368 {
369 Name: "testFunction",
370 ReturnType: phpString,
371 Params: []phpParameter{
372 {Name: "param", PhpType: phpString},
373 },
374 },
375 },
376 Classes: []phpClass{
377 {Name: "TestClass", GoStruct: "TestStruct"},
378 },
379 }
380
381 cGen := cFileGenerator{generator}
382 content, err := cGen.buildContent()
383 require.NoError(t, err)
384
385 syntaxElements := []string{
386 "{", "}", "(", ")", ";",
387 "static", "void", "int",
388 "#include",
389 }
390
391 for _, element := range syntaxElements {
392 assert.Contains(t, content, element, "Generated C content should contain basic C syntax: %s", element)
393 }
394
395 openBraces := strings.Count(content, "{")
396 closeBraces := strings.Count(content, "}")
397
398 assert.Equal(t, openBraces, closeBraces, "Unbalanced braces in generated C code: %d open, %d close", openBraces, closeBraces)
399 assert.False(t, strings.Contains(content, ";;"), "Generated C code contains double semicolons")
400 assert.False(t, strings.Contains(content, "{{") || strings.Contains(content, "}}"), "Generated C code contains unresolved template syntax")
401}
402
403func TestCFileConstants(t *testing.T) {
404 tests := []struct {

Callers

nothing calls this directly

Calls 1

buildContentMethod · 0.95

Tested by

no test coverage detected