views:

174

answers:

3

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.

+1  A: 

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.

Randolpho
Thanks for the links. I have some legacy code I'm not ready to throw away (yet) -- and it is not in the one of the above languages. I need to check that URL parsing part of that code works correctly.
Alexander Gladysh
Well, actually, the Addressable::URI Ruby library was specifically created, because the URI library in the Ruby stdlib *does not* conform RfC3986 (and after several years of complaining and bug filing still doesn't). So, be careful with the term "solved problem". Remember: everybody laughed at ...
Jörg W Mittag
... Google, because web search was "solved problem", too. I mean, why would *anyone* ever want to use anything other than AltaVista?
Jörg W Mittag
+1  A: 

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

MarkusQ
+2  A: 

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.

Jörg W Mittag