summaryrefslogtreecommitdiffstats
path: root/test/src
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 /test/src
parent548ca64879a3831abe9102eedad87de0326c6099 (diff)
downloaduscxml-d1404b669a00a6cff2ac35f09d0222c1d9ab4bff.zip
uscxml-d1404b669a00a6cff2ac35f09d0222c1d9ab4bff.tar.gz
uscxml-d1404b669a00a6cff2ac35f09d0222c1d9ab4bff.tar.bz2
Added UTF8 tests
Diffstat (limited to 'test/src')
-rw-r--r--test/src/test-snippets.cpp3
-rw-r--r--test/src/test-utf8.cpp88
2 files changed, 89 insertions, 2 deletions
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;
+}