|
[
Permalink
| « Hide
]
Nicolas Connault added a comment - 22/Jun/09 02:05 PM
I'm changing the requirement of extracting "ALL" regular expressions. I think that only those that are difficult to read need to be unit-tested.
It depends.
I don't think a regular-expression is normally the right level of granularity to test. That is, unit test should test the external API of a unit of code, not the implementation details, and a regex is normally an implementation detail. So, as a simple example, we should not unit test '/[^A-Za-z0-9]/i', we should unit test clean_param(..., PARAM_ALPHANUM); Of course, if a regex is perfoming an important task all on its own, and that is currently buried in the middle of a big function, then it might be good to factor out the task done by the regex into a new function. |
||||||||||||||||||||||||||||||||||||||||||||||||||||