summaryrefslogtreecommitdiff
path: root/tests/url
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2012-07-28 21:28:00 +0200
committerAndreas Baumann <abaumann@yahoo.com>2012-07-28 21:28:00 +0200
commitff98cc74fd06ef167eb2404ce93051d92dd75caf (patch)
treeab71535e9fd32bd7d9fa122b3e7937633d819c0e /tests/url
parent3856d7214b3b3eb3e5b8c3ac025b7aeeb93cd044 (diff)
downloadcrawler-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-xtests/url/exec_test10
-rw-r--r--tests/url/test1.cpp5
-rw-r--r--tests/url/test2.cpp13
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