summaryrefslogtreecommitdiffstats
path: root/test/src/test-url.cpp
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-04-14 21:22:24 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-04-14 21:22:24 (GMT)
commit1c10bc4bf19c5ce73e3e10380e613da8bf93a1b0 (patch)
treed2f89e5c4564ef7e363f17eaee3800650a5ab4bd /test/src/test-url.cpp
parent631b88e42c3fb7e10dee390d170854e40c31fac0 (diff)
downloaduscxml-1c10bc4bf19c5ce73e3e10380e613da8bf93a1b0.zip
uscxml-1c10bc4bf19c5ce73e3e10380e613da8bf93a1b0.tar.gz
uscxml-1c10bc4bf19c5ce73e3e10380e613da8bf93a1b0.tar.bz2
Refactored URLs and fixed Windows URL handling
Diffstat (limited to 'test/src/test-url.cpp')
-rw-r--r--test/src/test-url.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/src/test-url.cpp b/test/src/test-url.cpp
index 86fcb9f..c889f86 100644
--- a/test/src/test-url.cpp
+++ b/test/src/test-url.cpp
@@ -3,6 +3,8 @@
#include "uscxml/Interpreter.h"
#include "uscxml/server/HTTPServer.h"
+#include <SAX/helpers/InputSourceResolver.hpp>
+
#include <assert.h>
#include <boost/algorithm/string.hpp>
#include <iostream>
@@ -26,8 +28,34 @@ public:
bool _canAdaptPath;
};
+bool canResolve(const std::string& url) {
+ Arabica::SAX::InputSource<std::string> is(url);
+ Arabica::SAX::InputSourceResolver res1(is, Arabica::default_string_adaptor<std::string>());
+ if(res1.resolve()) {
+ std::cout << "good: " << url << std::endl;
+ return true;
+ } else {
+ std::cout << "bad: " << url << std::endl;
+ return false;
+ }
+}
+
int main(int argc, char** argv) {
+ std::string exeName = argv[0];
+ exeName = exeName.substr(exeName.find_last_of("\\/") + 1);
+
+ {
+ URL url(argv[0]);
+ assert(canResolve(argv[0]));
+ assert(canResolve(url.asString()));
+
+ URL baseUrl = URL::asBaseURL(url);
+ URL exeUrl(exeName);
+ exeUrl.toAbsolute(baseUrl);
+ assert(canResolve(exeUrl.asString()));
+ }
+
{
// Interpreter interpreter = Interpreter::fromURI("https://raw.github.com/tklab-tud/uscxml/master/test/samples/uscxml/test-execution.scxml");
// assert(interpreter);