(t *testing.T, content, expectedGuard string)
| 297 | } |
| 298 | |
| 299 | func testHeaderIncludeGuards(t *testing.T, content, expectedGuard string) { |
| 300 | expectedIfndef := "#ifndef _" + expectedGuard |
| 301 | expectedDefine := "#define _" + expectedGuard |
| 302 | |
| 303 | assert.Contains(t, content, expectedIfndef, "Header should contain: %s", expectedIfndef) |
| 304 | assert.Contains(t, content, expectedDefine, "Header should contain: %s", expectedDefine) |
| 305 | assert.Contains(t, content, "#endif", "Header should end with #endif") |
| 306 | |
| 307 | ifndefPos := strings.Index(content, expectedIfndef) |
| 308 | definePos := strings.Index(content, expectedDefine) |
| 309 | |
| 310 | assert.Less(t, ifndefPos, definePos, "#ifndef should come before #define") |
| 311 | |
| 312 | endifPos := strings.LastIndex(content, "#endif") |
| 313 | assert.NotEqual(t, -1, endifPos, "Header should end with #endif") |
| 314 | assert.Greater(t, endifPos, definePos, "#endif should come after #define") |
| 315 | } |
no outgoing calls
no test coverage detected