How can I unit/integration test a program's ANSI escape code behavior?
问题 I've started adding some coloring and other functionality (line resets, etc.) to my application and would like to have some unit tests covering the behavior. I know I could just assert that the output contains the appropriate \e[... codes, but that's brittle. For one, it would fail if it were swapped to \033 or otherwise refactored in trivial but not identical ways. More to the point however, testing the sequence of characters doesn't really do what I want. I want to assert or verify that the