summaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-12-20 00:56:45 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-12-20 00:56:45 (GMT)
commit0388c7ac478187ff8d264b6e0275a4c4a43796b9 (patch)
tree7e62439ebf72b6369ee7b1daa370e6251c06b7e0 /test/src
parent22e22bfd0965e01fea041e053873d352387805f6 (diff)
downloaduscxml-0388c7ac478187ff8d264b6e0275a4c4a43796b9.zip
uscxml-0388c7ac478187ff8d264b6e0275a4c4a43796b9.tar.gz
uscxml-0388c7ac478187ff8d264b6e0275a4c4a43796b9.tar.bz2
Performance and bugfix for WebSockets
Diffstat (limited to 'test/src')
-rw-r--r--test/src/test-base64.cpp18
-rw-r--r--test/src/test-predicates.cpp66
2 files changed, 78 insertions, 6 deletions
diff --git a/test/src/test-base64.cpp b/test/src/test-base64.cpp
new file mode 100644
index 0000000..1267b7b
--- /dev/null
+++ b/test/src/test-base64.cpp
@@ -0,0 +1,18 @@
+#include "uscxml/util/Base64.hpp"
+#include <assert.h>
+
+#define SOURCE_LEN 10
+
+int main(int argc, char** argv) {
+ std::string data;
+ std::string base64CPP;
+ std::string base64C;
+
+ char buffer[SOURCE_LEN];
+ for (int i = 0; i < SOURCE_LEN; i++) {
+ buffer[i] = (char)55;
+ }
+
+ base64C = uscxml::base64Encode(buffer, SOURCE_LEN);
+
+} \ No newline at end of file
diff --git a/test/src/test-predicates.cpp b/test/src/test-predicates.cpp
index b3e46fe..ed155b4 100644
--- a/test/src/test-predicates.cpp
+++ b/test/src/test-predicates.cpp
@@ -43,12 +43,66 @@ int main(int argc, char** argv) {
assert(Interpreter::isDescendant(compoundChild1, compoundState));
- std::string idrefs("id1 \nid2 \tid3");
- std::vector<std::string> tokenizedIdrefs = Interpreter::tokenizeIdRefs(idrefs);
- assert(tokenizedIdrefs.size() == 3);
- assert(tokenizedIdrefs[0].compare("id1") == 0);
- assert(tokenizedIdrefs[1].compare("id2") == 0);
- assert(tokenizedIdrefs[2].compare("id3") == 0);
+ {
+ std::string idrefs("id1");
+ std::list<std::string> tokenizedIdrefs = Interpreter::tokenizeIdRefs(idrefs);
+ assert(tokenizedIdrefs.size() == 1);
+ assert(tokenizedIdrefs.front().compare("id1") == 0);
+ }
+
+ {
+ std::string idrefs(" id1");
+ std::list<std::string> tokenizedIdrefs = Interpreter::tokenizeIdRefs(idrefs);
+ assert(tokenizedIdrefs.size() == 1);
+ assert(tokenizedIdrefs.front().compare("id1") == 0);
+ }
+
+ {
+ std::string idrefs(" id1 ");
+ std::list<std::string> tokenizedIdrefs = Interpreter::tokenizeIdRefs(idrefs);
+ assert(tokenizedIdrefs.size() == 1);
+ assert(tokenizedIdrefs.front().compare("id1") == 0);
+ }
+
+ {
+ std::string idrefs(" \tid1\n ");
+ std::list<std::string> tokenizedIdrefs = Interpreter::tokenizeIdRefs(idrefs);
+ assert(tokenizedIdrefs.size() == 1);
+ assert(tokenizedIdrefs.front().compare("id1") == 0);
+ }
+
+ {
+ std::string idrefs("id1 id2 id3");
+ std::list<std::string> tokenizedIdrefs = Interpreter::tokenizeIdRefs(idrefs);
+ assert(tokenizedIdrefs.size() == 3);
+ assert(tokenizedIdrefs.front().compare("id1") == 0);
+ tokenizedIdrefs.pop_front();
+ assert(tokenizedIdrefs.front().compare("id2") == 0);
+ tokenizedIdrefs.pop_front();
+ assert(tokenizedIdrefs.front().compare("id3") == 0);
+ }
+
+ {
+ std::string idrefs("\t id1 \nid2\n\n id3\t");
+ std::list<std::string> tokenizedIdrefs = Interpreter::tokenizeIdRefs(idrefs);
+ assert(tokenizedIdrefs.size() == 3);
+ assert(tokenizedIdrefs.front().compare("id1") == 0);
+ tokenizedIdrefs.pop_front();
+ assert(tokenizedIdrefs.front().compare("id2") == 0);
+ tokenizedIdrefs.pop_front();
+ assert(tokenizedIdrefs.front().compare("id3") == 0);
+ }
+
+ {
+ std::string idrefs("id1 \nid2 \tid3");
+ std::list<std::string> tokenizedIdrefs = Interpreter::tokenizeIdRefs(idrefs);
+ assert(tokenizedIdrefs.size() == 3);
+ assert(tokenizedIdrefs.front().compare("id1") == 0);
+ tokenizedIdrefs.pop_front();
+ assert(tokenizedIdrefs.front().compare("id2") == 0);
+ tokenizedIdrefs.pop_front();
+ assert(tokenizedIdrefs.front().compare("id3") == 0);
+ }
std::string transEvents;
transEvents = "error";