summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Radomski <github@mintwerk.de>2017-06-02 12:54:23 (GMT)
committerStefan Radomski <github@mintwerk.de>2017-06-02 12:54:23 (GMT)
commitd1404b669a00a6cff2ac35f09d0222c1d9ab4bff (patch)
tree3e6b6201089104f37816d7ad14b608b859178a61
parent548ca64879a3831abe9102eedad87de0326c6099 (diff)
downloaduscxml-d1404b669a00a6cff2ac35f09d0222c1d9ab4bff.zip
uscxml-d1404b669a00a6cff2ac35f09d0222c1d9ab4bff.tar.gz
uscxml-d1404b669a00a6cff2ac35f09d0222c1d9ab4bff.tar.bz2
Added UTF8 tests
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/uscxml/Interpreter.cpp12
-rw-r--r--src/uscxml/server/HTTPServer.cpp4
-rw-r--r--test/CMakeLists.txt1
-rw-r--r--test/src/test-snippets.cpp3
-rw-r--r--test/src/test-utf8.cpp88
6 files changed, 99 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 48c8133..5f1fecb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -390,6 +390,7 @@ find_package(SWIG)
# JavaScriptCore
+# https://github.com/Lichtso/JSC-Standalone
OPTION(WITH_DM_ECMA_JSC "Do search for JavaScriptCore" ON)
if (WITH_DM_ECMA_JSC)
find_package(JSC)
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index 0758cd1..59a5084 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -98,7 +98,7 @@ Interpreter Interpreter::fromXML(const std::string& xml, const std::string& base
Interpreter Interpreter::fromElement(XERCESC_NS::DOMElement* scxml, const std::string& baseURL) {
URL absUrl = normalizeURL(baseURL);
-
+
std::shared_ptr<InterpreterImpl> interpreterImpl(new InterpreterImpl());
Interpreter interpreter(interpreterImpl);
@@ -148,12 +148,12 @@ Interpreter Interpreter::fromURL(const std::string& url) {
URL absUrl = normalizeURL(url);
#ifdef _WIN32
- // Xercesc is hard to build with SSL on windows, whereas curl uses winssl
- if (absUrl.scheme() == "https") {
- return fromXML(absUrl.getInContent(), absUrl);
- }
+ // Xercesc is hard to build with SSL on windows, whereas curl uses winssl
+ if (absUrl.scheme() == "https") {
+ return fromXML(absUrl.getInContent(), absUrl);
+ }
#endif
-
+
std::shared_ptr<InterpreterImpl> interpreterImpl(new InterpreterImpl());
Interpreter interpreter(interpreterImpl);
diff --git a/src/uscxml/server/HTTPServer.cpp b/src/uscxml/server/HTTPServer.cpp
index e9a1039..aa43002 100644
--- a/src/uscxml/server/HTTPServer.cpp
+++ b/src/uscxml/server/HTTPServer.cpp
@@ -129,7 +129,7 @@ HTTPServer::HTTPServer(unsigned short port, unsigned short wsPort, SSLConfig* ss
SSL_library_init ();
SSL_load_error_strings ();
- ERR_load_crypto_strings();
+ ERR_load_crypto_strings();
OpenSSL_add_all_algorithms ();
SSL_CTX *ctx = SSL_CTX_new (SSLv23_server_method ());
@@ -144,7 +144,7 @@ HTTPServer::HTTPServer(unsigned short port, unsigned short wsPort, SSLConfig* ss
goto FAIL_SSL_SETUP;
}
if (1 != SSL_CTX_set_tmp_ecdh (ctx, ecdh)) {
- LOGD(USCXML_ERROR) << ("SSL_CTX_set_tmp_ecdh") << ERR_error_string(ERR_get_error(), NULL);
+ LOGD(USCXML_ERROR) << ("SSL_CTX_set_tmp_ecdh") << ERR_error_string(ERR_get_error(), NULL);
goto FAIL_SSL_SETUP;
}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index e76e249..9e5b61f 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -60,6 +60,7 @@ if(WITH_DM_LUA AND NOT BUILD_AS_PLUGINS)
../contrib/src/uscxml/CustomExecutableContent.cpp)
endif()
USCXML_TEST_COMPILE(NAME test-url LABEL general/test-url FILES src/test-url.cpp)
+USCXML_TEST_COMPILE(NAME test-utf8 LABEL general/test-utf8 FILES src/test-utf8.cpp)
USCXML_TEST_COMPILE(NAME test-lifecycle LABEL general/test-lifecycle FILES src/test-lifecycle.cpp)
USCXML_TEST_COMPILE(NAME test-validating LABEL general/test-validating FILES src/test-validating.cpp)
USCXML_TEST_COMPILE(NAME test-snippets LABEL general/test-snippets FILES src/test-snippets.cpp)
diff --git a/test/src/test-snippets.cpp b/test/src/test-snippets.cpp
index 581a258..f26b730 100644
--- a/test/src/test-snippets.cpp
+++ b/test/src/test-snippets.cpp
@@ -35,8 +35,7 @@ int main(int argc, char** argv) {
try {
Logger::getDefault().log(USCXML_FATAL) << "Foo!" << " BAR?" << std::endl;
microstep_snippet();
- }
- catch (...) {
+ } catch (...) {
exit(EXIT_FAILURE);
}
}
diff --git a/test/src/test-utf8.cpp b/test/src/test-utf8.cpp
new file mode 100644
index 0000000..37aace0
--- /dev/null
+++ b/test/src/test-utf8.cpp
@@ -0,0 +1,88 @@
+#include "uscxml/config.h"
+#include "uscxml/Interpreter.h"
+#include "uscxml/plugins/Factory.h"
+#include "uscxml/plugins/DataModelImpl.h"
+
+#include <iostream>
+#include <cassert>
+
+/*
+#define WITH_DM_ECMA_V8
+#define WITH_DM_ECMA_JSC
+#define WITH_DM_LUA
+#define WITH_DM_PYTHON
+#define WITH_DM_C89
+#define WITH_DM_PROMELA
+*/
+
+using namespace uscxml;
+
+class TestDataModelCallbacks : public DataModelCallbacks {
+public:
+ std::string _name = "name";
+ std::string _sessionId = "sessionId";
+ std::map<std::string, IOProcessor> _ioProcs;
+ std::map<std::string, Invoker> _invokers;
+
+ const std::string& getName() {
+ return _name;
+ }
+ const std::string& getSessionId() {
+ return _sessionId;
+ }
+ const std::map<std::string, IOProcessor>& getIOProcessors() {
+ return _ioProcs;
+ }
+ virtual bool isInState(const std::string& stateId) {
+ return true;
+ }
+ XERCESC_NS::DOMDocument* getDocument() const {
+ return NULL;
+ }
+ const std::map<std::string, Invoker>& getInvokers() {
+ return _invokers;
+ }
+ Logger getLogger() {
+ return Logger::getDefault();
+ }
+
+};
+
+TestDataModelCallbacks dmCallbacks;
+std::list<std::string> datamodels;
+
+bool testSimpleJSON() {
+ for (auto dmName : datamodels) {
+ std::cout << "** " << dmName << ":" << std::endl;
+ DataModel dm = Factory::getInstance()->createDataModel(dmName, &dmCallbacks);
+ Data json = Data::fromJSON("{\"ü\": \"ä\"}");
+ dm.init("foo", json);
+ Data json2 = dm.evalAsData("foo");
+ std::cout << json << std::endl;
+ std::cout << json2 << std::endl;
+ assert(json == json2);
+
+ dm.init("bar", Data("ö", Data::VERBATIM));
+ bool cmp = dm.evalAsBool("bar == \"ö\"");
+ std::cout << dm.evalAsData("bar") << std::endl;
+ assert(cmp);
+
+ }
+ return true;
+}
+
+
+int main(int argc, char** argv) {
+#ifdef WITH_DM_LUA
+ datamodels.push_back("lua");
+#endif
+#ifdef WITH_DM_PROMELA
+// datamodels.push_back("promela");
+#endif
+#if (defined WITH_DM_ECMA_V8 || defined WITH_DM_ECMA_JSC)
+ datamodels.push_back("ecmascript");
+#endif
+
+ testSimpleJSON();
+ return EXIT_SUCCESS;
+}