TestRemoveXMLCommentsEdgeCases tests various edge cases and boundary conditions
(t *testing.T)
| 547 | |
| 548 | // TestRemoveXMLCommentsEdgeCases tests various edge cases and boundary conditions |
| 549 | func TestRemoveXMLCommentsEdgeCases(t *testing.T) { |
| 550 | tests := []struct { |
| 551 | name string |
| 552 | input string |
| 553 | expected string |
| 554 | }{ |
| 555 | { |
| 556 | name: "Empty string", |
| 557 | input: "", |
| 558 | expected: "", |
| 559 | }, |
| 560 | { |
| 561 | name: "Only whitespace", |
| 562 | input: " \n\t\n ", |
| 563 | expected: " \n\t\n ", |
| 564 | }, |
| 565 | { |
| 566 | name: "Only XML comment opening without closing", |
| 567 | input: "<!-- unclosed comment", |
| 568 | expected: "", |
| 569 | }, |
| 570 | { |
| 571 | name: "Only XML comment closing without opening", |
| 572 | input: "closing without opening -->", |
| 573 | expected: "closing without opening -->", |
| 574 | }, |
| 575 | { |
| 576 | name: "Comment markers in text are processed as comments", |
| 577 | input: `Text with "<!--" in quotes and "-->" also in quotes`, |
| 578 | expected: `Text with "" also in quotes`, |
| 579 | }, |
| 580 | { |
| 581 | name: "XML comment spanning entire content", |
| 582 | input: `<!-- Everything is commented |
| 583 | Line 2 |
| 584 | Line 3 |
| 585 | Last line -->`, |
| 586 | expected: "", |
| 587 | }, |
| 588 | { |
| 589 | name: "Multiple consecutive XML comments", |
| 590 | input: `Text |
| 591 | <!-- Comment 1 --> |
| 592 | <!-- Comment 2 --> |
| 593 | <!-- Comment 3 --> |
| 594 | More text`, |
| 595 | expected: `Text |
| 596 | |
| 597 | |
| 598 | |
| 599 | More text`, |
| 600 | }, |
| 601 | { |
| 602 | name: "XML comment with code block markers but incomplete blocks", |
| 603 | input: `Before |
| 604 | <!-- |
| 605 | ` + "```" + ` |
| 606 | This code block is never closed |
nothing calls this directly
no test coverage detected