Question

I need to test some existing http:// URL parsing code for compliance to RFC 3986.

I do not want to reinvent the wheel and to bump in to various corner cases.

Is there some existing comprehensive test suite for that?

I do not specify the language I use since I expect the test suite to be generic enough to be adaptable. I would settle for anything sane though.

Was it helpful?

Solution

The Addressable Ruby library has a very comprehensive Spec Suite (618 examples with 800 expectations in 123 example groups, weighing in at over 3700 SLOC), which covers large parts of RfC3986. The code is here. I'm not sure how directly you can run this on your library, maybe you can get it working unmodified, by writing a simple API-compatible Ruby-wrapper for your library? Otherwise, the Spec is really well patterned, so you should be able to get pretty far with some simple Rename Method Refactorings and Regexp-fu.

OTHER TIPS

Here's a small one for RFC 2396, which I think came from here, if it helps. Also this.

Hmm... parsing URLs is pretty much a solved problem these days. Most major languages have a URI class or function that does all the parsing you need. Are you sure you really need to roll your own?

Here are some links to URI modules in popular languages these days:

Since you're testing existing code, you could use those classes/functions as your expected values for that code. Just build up a bunch of different types of valid and invalid URIs and go to town.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top