BenchmarkUnquoteYAMLKey measures single-pass regex replacement performance. This benchmark guards against regressions where the implementation calls FindStringSubmatch inside a ReplaceAllStringFunc callback (double regex pass).
(b *testing.B)
| 511 | // This benchmark guards against regressions where the implementation calls |
| 512 | // FindStringSubmatch inside a ReplaceAllStringFunc callback (double regex pass). |
| 513 | func BenchmarkUnquoteYAMLKey(b *testing.B) { |
| 514 | // A realistic workflow YAML with the "on" key quoted by the marshaler |
| 515 | yamlStr := `"on": |
| 516 | push: |
| 517 | branches: |
| 518 | - main |
| 519 | pull_request: |
| 520 | types: |
| 521 | - opened |
| 522 | - synchronize |
| 523 | issues: |
| 524 | types: |
| 525 | - opened |
| 526 | workflow_dispatch: |
| 527 | jobs: |
| 528 | agent: |
| 529 | runs-on: ubuntu-latest |
| 530 | steps: |
| 531 | - name: Run |
| 532 | run: echo hello |
| 533 | ` |
| 534 | b.ReportAllocs() |
| 535 | for b.Loop() { |
| 536 | _ = UnquoteYAMLKey(yamlStr, "on") |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | func TestFormatYAMLValue(t *testing.T) { |
| 541 | tests := []struct { |
nothing calls this directly
no test coverage detected