Tests with bad errors
I am working on a function to validate http addresses. I need good and bad urls for unit testing. Please share your test cases with me.
Thank.
There are many permutations and combinations ... also how strictly you follow the standard specifications is something to worry about
Which protocols are supported ... is it just http ... or https, rmtp, etc.
Consider things like domains and subdomains ... www.google.com and www.maps.google.com are valid
The presence or absence of a trailing slash
Non-standard port ... http://www.example.com:8800
Deep path after host ... http://www.example.com/a/b/c/d/e/f/g/h/i.html
URL options ... http://www.test.com?pageid=123&testid=1524
URL encoding ... and how URLs are URL encoded if they are part of parameters
Anchor Tags ... http://www.test.com/do.html#A
The presence of special characters ... if any
whitespace handling
Maximum and minimum URL size
Interesting!!
Have you researched in existing libraries that allow you to validate urls
I would look at RFC1738 to find test cases. For example, start using a schema (eg wibble: //www.bbc.co.uk). This should be invalid.
Define "bad"?
Characters that should have been escaped?
http://stackoverflow.com/users/9999999/not a-real-user
Accidentally transposed characters?
http//:stackoverflow.com/questions/9715606/bad-url-test-cases
URLs that just result in 404s?
http://stackoverflow.com/users/9999999/not-a-real-user