diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2012-07-28 21:28:00 +0200 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2012-07-28 21:28:00 +0200 |
commit | ff98cc74fd06ef167eb2404ce93051d92dd75caf (patch) | |
tree | ab71535e9fd32bd7d9fa122b3e7937633d819c0e /tests/url | |
parent | 3856d7214b3b3eb3e5b8c3ac025b7aeeb93cd044 (diff) | |
download | crawler-ff98cc74fd06ef167eb2404ce93051d92dd75caf.tar.gz crawler-ff98cc74fd06ef167eb2404ce93051d92dd75caf.tar.bz2 |
heavy redesign of URL class, must not contain any parsing logic as
it is the caninic representation
URLNormalizers are used for intepreting strings and contexts as URL
currently nothing runs :-)
Diffstat (limited to 'tests/url')
-rwxr-xr-x | tests/url/exec_test | 10 | ||||
-rw-r--r-- | tests/url/test1.cpp | 5 | ||||
-rw-r--r-- | tests/url/test2.cpp | 13 |
3 files changed, 18 insertions, 10 deletions
diff --git a/tests/url/exec_test b/tests/url/exec_test new file mode 100755 index 0000000..8628c2d --- /dev/null +++ b/tests/url/exec_test @@ -0,0 +1,10 @@ +#!/bin/sh + +BINARY=$1 +shift +TITLE=$1 +shift + +printf "$BINARY: $TITLE .. " +./$BINARY $* >$BINARY.RES 2>&1 +diff $BINARY.MUST $BINARY.RES > $BINARY.DIFF && printf "OK\n" || printf "ERROR\n" diff --git a/tests/url/test1.cpp b/tests/url/test1.cpp index 64ae223..677bf10 100644 --- a/tests/url/test1.cpp +++ b/tests/url/test1.cpp @@ -1,4 +1,5 @@ #include "URL.hpp" +#include "SimpleURLNormalizer.hpp" #include <iostream> #include <string> @@ -14,7 +15,9 @@ int main( int argc, char *argv[] ) char *urlstring = argv[1]; - URL url( urlstring ); + URLNormalizer *normalizer = new SimpleURLNormalizer( ); + URL url = normalizer->parseUrl( urlstring ); + delete normalizer; cout << "protocol: " << url.protocol( ) << endl << "port: " << url.port( ) << endl diff --git a/tests/url/test2.cpp b/tests/url/test2.cpp index b9a3270..7bf135a 100644 --- a/tests/url/test2.cpp +++ b/tests/url/test2.cpp @@ -16,16 +16,11 @@ int main( int argc, char *argv[] ) char *baseUrlString = argv[1]; char *partialUrlString = argv[2]; - URL baseUrl( baseUrlString ); - URL partialUrl( partialUrlString ); - - URL url = baseUrl; URLNormalizer *normalizer = new SimpleURLNormalizer( ); - if( !normalizer->normalize( url, partialUrl ) ) { - delete normalizer; - cerr << "Normalization error!\n" << endl; - return 1; - } + + URL baseUrl = normalizer->parseUrl( baseUrlString ); + + URL url = normalizer->normalize( baseUrl, partialUrlString ); cout << "protocol: " << url.protocol( ) << endl << "port: " << url.port( ) << endl |