(t *testing.T)
| 31 | } |
| 32 | |
| 33 | func TestHeaderGenerator_BuildContent(t *testing.T) { |
| 34 | tests := []struct { |
| 35 | name string |
| 36 | baseName string |
| 37 | contains []string |
| 38 | }{ |
| 39 | { |
| 40 | name: "simple extension", |
| 41 | baseName: "simple", |
| 42 | contains: []string{ |
| 43 | "#ifndef _SIMPLE_H", |
| 44 | "#define _SIMPLE_H", |
| 45 | "#include <php.h>", |
| 46 | "extern zend_module_entry simple_module_entry;", |
| 47 | "#endif", |
| 48 | }, |
| 49 | }, |
| 50 | { |
| 51 | name: "extension with hyphens", |
| 52 | baseName: "my-extension", |
| 53 | contains: []string{ |
| 54 | "#ifndef _MY_EXTENSION_H", |
| 55 | "#define _MY_EXTENSION_H", |
| 56 | "#endif", |
| 57 | }, |
| 58 | }, |
| 59 | { |
| 60 | name: "extension with underscores", |
| 61 | baseName: "my_extension_name", |
| 62 | contains: []string{ |
| 63 | "#ifndef _MY_EXTENSION_NAME_H", |
| 64 | "#define _MY_EXTENSION_NAME_H", |
| 65 | "#endif", |
| 66 | }, |
| 67 | }, |
| 68 | { |
| 69 | name: "complex extension name", |
| 70 | baseName: "complex.name-with_symbols", |
| 71 | contains: []string{ |
| 72 | "#ifndef _COMPLEX_NAME_WITH_SYMBOLS_H", |
| 73 | "#define _COMPLEX_NAME_WITH_SYMBOLS_H", |
| 74 | "#endif", |
| 75 | }, |
| 76 | }, |
| 77 | } |
| 78 | |
| 79 | for _, tt := range tests { |
| 80 | t.Run(tt.name, func(t *testing.T) { |
| 81 | generator := &Generator{BaseName: tt.baseName} |
| 82 | headerGen := HeaderGenerator{generator} |
| 83 | content, err := headerGen.buildContent() |
| 84 | require.NoError(t, err) |
| 85 | |
| 86 | for _, expected := range tt.contains { |
| 87 | assert.Contains(t, content, expected, "Generated header content should contain '%s'", expected) |
| 88 | } |
| 89 | }) |
| 90 | } |
nothing calls this directly
no test coverage detected