diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 5 | ||||
-rw-r--r-- | test/src/test-url.cpp | 42 |
2 files changed, 47 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 39a4667..353faa2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -53,3 +53,8 @@ add_executable(test-arabica-events src/test-arabica-events.cpp) target_link_libraries(test-arabica-events uscxml) add_test(test-arabica-events ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-arabica-events ${CMAKE_SOURCE_DIR}/test/samples/arabica/test-arabica-events.xml) set_target_properties(test-arabica-events PROPERTIES FOLDER "Tests") + +add_executable(test-url src/test-url.cpp) +target_link_libraries(test-url uscxml) +add_test(test-url ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-url) +set_target_properties(test-url PROPERTIES FOLDER "Tests") diff --git a/test/src/test-url.cpp b/test/src/test-url.cpp new file mode 100644 index 0000000..e7fbae4 --- /dev/null +++ b/test/src/test-url.cpp @@ -0,0 +1,42 @@ +#include "uscxml/URL.h" +#include <assert.h> +#include <boost/algorithm/string.hpp> + +using namespace uscxml; +using namespace boost; + +int main(int argc, char** argv) { + { + URL url("http://www.heise.de/index.html"); + std::cout << url.asString() << std::endl; + assert(url.isAbsolute()); + assert(iequals(url.scheme(), "http")); + assert(iequals(url.host(), "www.heise.de")); + assert(iequals(url.port(), "80")); + assert(iequals(url.path(), "/index.html")); + assert(iequals(url.asString(), "http://www.heise.de/index.html")); + } + { + URL url("file:Document/Text.foo"); + std::cout << url.asString() << std::endl; + assert(!url.isAbsolute()); + assert(iequals(url.scheme(), "file")); + assert(iequals(url.host(), "")); + assert(iequals(url.port(), "0")); + assert(iequals(url.path(), "Document/Text.foo")); + assert(iequals(url.asString(), "file:Document/Text.foo")); + } + { + URL url("test/index.html"); + assert(iequals(url.scheme(), "")); + url.toAbsoluteCwd(); + assert(iequals(url.scheme(), "file")); + std::cout << url.asString() << std::endl; + } + { + URL url("C:\\Document\\Some Spaces\\index.txt"); + assert(url.isAbsolute()); + assert(iequals(url.scheme(), "file")); + std::cout << url.asString() << std::endl; + } +}
\ No newline at end of file |