summaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-10-12 11:11:06 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-10-12 11:11:06 (GMT)
commitfa90b5749693d9f5817ad1f106334a0877171fd3 (patch)
tree8d53b5c820590cad54893bc575ef55df38f55d23 /test/src
parentc36b123a60278caef5d06e8a7d0b3d338d669c75 (diff)
downloaduscxml-fa90b5749693d9f5817ad1f106334a0877171fd3.zip
uscxml-fa90b5749693d9f5817ad1f106334a0877171fd3.tar.gz
uscxml-fa90b5749693d9f5817ad1f106334a0877171fd3.tar.bz2
Major work on PROMELA datamodel
Diffstat (limited to 'test/src')
-rw-r--r--test/src/test-flat-stateid.cpp12
-rw-r--r--test/src/test-issue-reporting.cpp352
-rw-r--r--test/src/test-mmi.cpp30
-rw-r--r--test/src/test-promela-parser.cpp18
-rw-r--r--test/src/test-sockets.cpp10
-rw-r--r--test/src/test-url.cpp2
-rw-r--r--test/src/test-vxml-mmi-http.cpp65
-rw-r--r--test/src/test-vxml-mmi-socket.cpp30
-rw-r--r--test/src/test-w3c.cpp36
9 files changed, 284 insertions, 271 deletions
diff --git a/test/src/test-flat-stateid.cpp b/test/src/test-flat-stateid.cpp
index 719e4ee..7820d61 100644
--- a/test/src/test-flat-stateid.cpp
+++ b/test/src/test-flat-stateid.cpp
@@ -10,7 +10,7 @@ int main(int argc, char** argv) {
assert(flat1.getActive().size() == 0);
assert(flat1.getVisited().size() == 0);
assert(flat1.getHistory().size() == 0);
-
+
uscxml::FlatStateIdentifier flat2(flat1.getActive(), flat1.getVisited(), flat1.getHistory());
assert(flat2.getStateId() == stateId);
}
@@ -21,26 +21,26 @@ int main(int argc, char** argv) {
assert(flat1.getActive().size() == 1);
assert(flat1.getVisited().size() == 2);
assert(flat1.getHistory().size() == 0);
-
+
uscxml::FlatStateIdentifier flat2(flat1.getActive(), flat1.getVisited(), flat1.getHistory());
assert(flat2.getStateId() == stateId);
}
{
-
+
std::string stateId = "active:{s0,s1,s2};visited:{s0,s1,s2};history:{h0:{s1,s2},h1:{s2,s3}}";
uscxml::FlatStateIdentifier flat1(stateId);
-
+
listIter = flat1.getActive().begin();
assert(*listIter++ == "s0");
assert(*listIter++ == "s1");
assert(*listIter++ == "s2");
-
+
listIter = flat1.getVisited().begin();
assert(*listIter++ == "s0");
assert(*listIter++ == "s1");
assert(*listIter++ == "s2");
-
+
assert(flat1.getHistory().find("h0") != flat1.getHistory().end());
listIter = flat1.getHistory().at("h0").begin();
assert(*listIter++ == "s1");
diff --git a/test/src/test-issue-reporting.cpp b/test/src/test-issue-reporting.cpp
index cd1687c..39dad05 100644
--- a/test/src/test-issue-reporting.cpp
+++ b/test/src/test-issue-reporting.cpp
@@ -7,9 +7,9 @@ using namespace uscxml;
std::set<std::string> issueLocationsForXML(const std::string xml) {
Interpreter interpreter = Interpreter::fromXML(xml);
std::list<InterpreterIssue> issues = interpreter.validate();
-
+
std::set<std::string> issueLocations;
-
+
for (std::list<InterpreterIssue>::iterator issueIter = issues.begin(); issueIter != issues.end(); issueIter++) {
std::cout << *issueIter << std::endl;
issueLocations.insert(issueIter->xPath);
@@ -20,7 +20,9 @@ std::set<std::string> issueLocationsForXML(const std::string xml) {
size_t runtimeIssues;
class IssueMonitor : public InterpreterMonitor {
public:
- IssueMonitor() { runtimeIssues = 0; }
+ IssueMonitor() {
+ runtimeIssues = 0;
+ }
void reportIssue(Interpreter interpreter, const InterpreterIssue& issue) {
runtimeIssues++;
}
@@ -37,42 +39,42 @@ int main(int argc, char** argv) {
if (1) {
// Potential endless loop
-
+
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <datamodel><data id=\"counter\" expr=\"5\" /></datamodel>"
- " <state id=\"foo\">"
- " <onentry><script>counter--;</script></onentry>"
- " <transition target=\"foo\" cond=\"counter > 0\" />"
- " <transition target=\"bar\" cond=\"counter == 0\" />"
- " </state>"
- " <state id=\"bar\" final=\"true\" />"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\">"
+ " <datamodel><data id=\"counter\" expr=\"5\" /></datamodel>"
+ " <state id=\"foo\">"
+ " <onentry><script>counter--;</script></onentry>"
+ " <transition target=\"foo\" cond=\"counter > 0\" />"
+ " <transition target=\"bar\" cond=\"counter == 0\" />"
+ " </state>"
+ " <state id=\"bar\" final=\"true\" />"
+ "</scxml>";
+
IssueMonitor monitor;
Interpreter interpreter = Interpreter::fromXML(xml);
interpreter.addMonitor(&monitor);
interpreter.interpret();
-
+
// first reiteration is not counted as it might be valid when raising internal errors
assert(runtimeIssues == 3);
}
if (1) {
// Unreachable states
-
+
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"foo\">"
- " <parallel id=\"foz\">"
- " <state id=\"s0\" />"
- " <state id=\"s1\" />"
- " <state id=\"s2\" />"
- " </parallel>"
- " </state>"
- " <state id=\"bar\" />"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"foo\">"
+ " <parallel id=\"foz\">"
+ " <state id=\"s0\" />"
+ " <state id=\"s1\" />"
+ " <state id=\"s2\" />"
+ " </parallel>"
+ " </state>"
+ " <state id=\"bar\" />"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("//state[@id=\"bar\"]") != issueLocations.end());
assert(issueLocations.size() == 1);
@@ -80,14 +82,14 @@ int main(int argc, char** argv) {
if (1) {
// Invalid parents
-
+
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <onentry>"
- " <cancel sendidexpr=\"foo\" />"
- " </onentry>"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\">"
+ " <onentry>"
+ " <cancel sendidexpr=\"foo\" />"
+ " </onentry>"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("/scxml[1]/onentry[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
@@ -96,11 +98,11 @@ int main(int argc, char** argv) {
if (1) {
// State has no 'id' attribute
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state>"
- " <transition/>"
- " </state>"
- "</scxml>";
+ "<scxml datamodel=\"ecmascript\">"
+ " <state>"
+ " <transition/>"
+ " </state>"
+ "</scxml>";
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("/scxml[1]/state[1]") != issueLocations.end());
@@ -110,11 +112,11 @@ int main(int argc, char** argv) {
if (1) {
// Duplicate state with id
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"start\" />"
- " <state id=\"start\" />"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"start\" />"
+ " <state id=\"start\" />"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end());
assert(issueLocations.size() == 1);
@@ -122,32 +124,32 @@ int main(int argc, char** argv) {
if (1) {
// Transition has non-existant target state
-
+
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"start\">"
- " <transition target=\"done\" />"
- " </state>"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"start\">"
+ " <transition target=\"done\" />"
+ " </state>"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("//state[@id=\"start\"]/transition[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
}
-
+
if (1) {
// Transition can never be optimally enabled (conditionless, eventless)
-
+
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"start\">"
- " <transition target=\"done\" />"
- " <transition target=\"done\" />"
- " </state>"
- " <final id=\"done\" />"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"start\">"
+ " <transition target=\"done\" />"
+ " <transition target=\"done\" />"
+ " </state>"
+ " <final id=\"done\" />"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("//state[@id=\"start\"]/transition[2]") != issueLocations.end());
assert(issueLocations.size() == 1);
@@ -155,29 +157,29 @@ int main(int argc, char** argv) {
if (1) {
// Transition can never be optimally enabled (conditionless, more events)
-
+
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"start\">"
- " <transition event=\"error\" target=\"done\" />"
- " <transition event=\"error.bar error.foo\" />"
- " </state>"
- " <final id=\"done\" />"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"start\">"
+ " <transition event=\"error\" target=\"done\" />"
+ " <transition event=\"error.bar error.foo\" />"
+ " </state>"
+ " <final id=\"done\" />"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("//state[@id=\"start\"]/transition[2]") != issueLocations.end());
assert(issueLocations.size() == 1);
}
-
+
if (1) {
// Initial attribute has invalid target state
-
+
const char* xml =
- "<scxml datamodel=\"ecmascript\" initial=\"foo\">"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\" initial=\"foo\">"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("/scxml[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
@@ -185,14 +187,14 @@ int main(int argc, char** argv) {
if (1) {
// Invoke with unknown type
-
+
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"start\">"
- " <invoke type=\"non-existant\" />"
- " </state>"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"start\">"
+ " <invoke type=\"non-existant\" />"
+ " </state>"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("//state[@id=\"start\"]/invoke[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
@@ -200,16 +202,16 @@ int main(int argc, char** argv) {
if (1) {
// Send to unknown IO Processor
-
+
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"start\">"
- " <onentry>"
- " <send type=\"non-existant\" />"
- " </onentry>"
- " </state>"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"start\">"
+ " <onentry>"
+ " <send type=\"non-existant\" />"
+ " </onentry>"
+ " </state>"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
@@ -217,11 +219,11 @@ int main(int argc, char** argv) {
if (1) {
// SCXML document requires unknown datamodel
-
+
const char* xml =
- "<scxml datamodel=\"non-existant\">"
- "</scxml>";
-
+ "<scxml datamodel=\"non-existant\">"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("/scxml[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
@@ -229,16 +231,16 @@ int main(int argc, char** argv) {
if (1) {
// Unknown executable content element
-
+
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"start\">"
- " <onentry>"
- " <nonexistant />"
- " </onentry>"
- " </state>"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"start\">"
+ " <onentry>"
+ " <nonexistant />"
+ " </onentry>"
+ " </state>"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/nonexistant[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
@@ -246,14 +248,14 @@ int main(int argc, char** argv) {
if (1) {
// Syntax error in script
-
+
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <script>"
- " $wfwegr^ "
- " </script>"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\">"
+ " <script>"
+ " $wfwegr^ "
+ " </script>"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("/scxml[1]/script[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
@@ -261,19 +263,19 @@ int main(int argc, char** argv) {
if (1) {
// Syntax error in cond attribute
-
+
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"start\">"
- " <onentry>"
- " <if cond=\"%2345\">"
- " <elseif cond=\"%2345\" />"
- " </if>"
- " </onentry>"
- " <transition cond=\"%2345\" />"
- " </state>"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"start\">"
+ " <onentry>"
+ " <if cond=\"%2345\">"
+ " <elseif cond=\"%2345\" />"
+ " </if>"
+ " </onentry>"
+ " <transition cond=\"%2345\" />"
+ " </state>"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("//state[@id=\"start\"]/transition[1]") != issueLocations.end());
assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/if[1]") != issueLocations.end());
@@ -283,24 +285,24 @@ int main(int argc, char** argv) {
if (1) {
// Syntax error in expr attribute
-
+
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <datamodel>"
- " <data id=\"foo\" expr=\"%2345\" />"
- " </datamodel>"
- " <state id=\"start\">"
- " <onentry>"
- " <log expr=\"%2345\" />"
- " <assign location=\"foo\" expr=\"%2345\" />"
- " <send>"
- " <param expr=\"%2345\" />"
- " <content expr=\"%2345\" />"
- " </send>"
- " </onentry>"
- " </state>"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\">"
+ " <datamodel>"
+ " <data id=\"foo\" expr=\"%2345\" />"
+ " </datamodel>"
+ " <state id=\"start\">"
+ " <onentry>"
+ " <log expr=\"%2345\" />"
+ " <assign location=\"foo\" expr=\"%2345\" />"
+ " <send>"
+ " <param expr=\"%2345\" />"
+ " <content expr=\"%2345\" />"
+ " </send>"
+ " </onentry>"
+ " </state>"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/log[1]") != issueLocations.end());
assert(issueLocations.find("//data[@id=\"foo\"]") != issueLocations.end());
@@ -312,17 +314,17 @@ int main(int argc, char** argv) {
if (1) {
// Syntax error with foreach
-
+
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"start\">"
- " <onentry>"
- " <foreach item=\"%2345\" index=\"%2345\" array=\"%2345\">"
- " </foreach>"
- " </onentry>"
- " </state>"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"start\">"
+ " <onentry>"
+ " <foreach item=\"%2345\" index=\"%2345\" array=\"%2345\">"
+ " </foreach>"
+ " </onentry>"
+ " </state>"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/foreach[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
@@ -330,16 +332,16 @@ int main(int argc, char** argv) {
if (1) {
// Syntax error with send
-
+
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"start\">"
- " <onentry>"
- " <send eventexpr=\"%2345\" targetexpr=\"%2345\" typeexpr=\"%2345\" idlocation=\"%2345\" delayexpr=\"%2345\" />"
- " </onentry>"
- " </state>"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"start\">"
+ " <onentry>"
+ " <send eventexpr=\"%2345\" targetexpr=\"%2345\" typeexpr=\"%2345\" idlocation=\"%2345\" delayexpr=\"%2345\" />"
+ " </onentry>"
+ " </state>"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
@@ -347,14 +349,14 @@ int main(int argc, char** argv) {
if (1) {
// Syntax error with invoke
-
+
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"start\">"
- " <invoke typeexpr=\"%2345\" srcexpr=\"%2345\" idlocation=\"%2345\" />"
- " </state>"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"start\">"
+ " <invoke typeexpr=\"%2345\" srcexpr=\"%2345\" idlocation=\"%2345\" />"
+ " </state>"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("//state[@id=\"start\"]/invoke[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
@@ -362,16 +364,16 @@ int main(int argc, char** argv) {
if (1) {
// Syntax error with cancel
-
+
const char* xml =
- "<scxml datamodel=\"ecmascript\">"
- " <state id=\"start\">"
- " <onentry>"
- " <cancel sendidexpr=\"%2345\" />"
- " </onentry>"
- " </state>"
- "</scxml>";
-
+ "<scxml datamodel=\"ecmascript\">"
+ " <state id=\"start\">"
+ " <onentry>"
+ " <cancel sendidexpr=\"%2345\" />"
+ " </onentry>"
+ " </state>"
+ "</scxml>";
+
std::set<std::string> issueLocations = issueLocationsForXML(xml);
assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/cancel[1]") != issueLocations.end());
assert(issueLocations.size() == 1);
diff --git a/test/src/test-mmi.cpp b/test/src/test-mmi.cpp
index eeb71ee..52deeef 100644
--- a/test/src/test-mmi.cpp
+++ b/test/src/test-mmi.cpp
@@ -30,14 +30,14 @@ int main(int argc, char** argv) {
// --- NewContextRequest
std::stringstream ss;
ss << "<mmi:mmi xmlns:mmi=\"http://www.w3.org/2008/04/mmi-arch\" version=\"1.0\"><mmi:NewContextRequest mmi:Source=\"someURI\" mmi:Target=\"someOtherURI\" mmi:RequestID=\"request-1\"></mmi:NewContextRequest></mmi:mmi>";
-
+
NewContextRequest msg = NewContextRequest::fromXML(xmlToDoc(ss.str()));
assert(boost::iequals(msg.tagName, "NewContextRequest"));
assert(boost::iequals(msg.source, "someURI"));
assert(boost::iequals(msg.target, "someOtherURI"));
assert(boost::iequals(msg.requestId, "request-1"));
assert(boost::iequals(msg.data, ""));
-
+
NewContextRequest msg2 = NewContextRequest::fromXML(msg.toXML());
assert(boost::iequals(msg2.tagName, "NewContextRequest"));
assert(boost::iequals(msg2.source, "someURI"));
@@ -50,7 +50,7 @@ int main(int argc, char** argv) {
xml1SS << msg.toXML();
xml2SS << msg2.toXML();
assert(xml1SS.str() == xml2SS.str());
-
+
Event ev = msg;
assert(ev.name == "mmi.request.newcontext");
assert(ev.origin == msg.source);
@@ -143,7 +143,7 @@ int main(int argc, char** argv) {
assert(boost::iequals(msg.requestId, "request-1"));
assert(boost::iequals(msg.context, "URI-1"));
assert(msg.contentDOM);
-
+
PrepareRequest msg2 = PrepareRequest::fromXML(msg.toXML());
assert(boost::iequals(msg2.tagName, "PrepareRequest"));
assert(boost::iequals(msg2.source, "someURI"));
@@ -270,29 +270,29 @@ int main(int argc, char** argv) {
assert(boost::iequals(msg.target, "someOtherURI"));
assert(boost::iequals(msg.requestId, "request-1"));
assert(boost::iequals(msg.context, "URI-1"));
-
+
StartRequest msg2 = StartRequest::fromXML(msg.toXML());
assert(boost::iequals(msg2.tagName, "StartRequest"));
assert(boost::iequals(msg2.source, "someURI"));
assert(boost::iequals(msg2.target, "someOtherURI"));
assert(boost::iequals(msg2.requestId, "request-1"));
assert(boost::iequals(msg2.context, "URI-1"));
-
+
std::stringstream xml1SS;
std::stringstream xml2SS;
xml1SS << msg.toXML();
xml2SS << msg2.toXML();
assert(xml1SS.str() == xml2SS.str());
-
+
Event ev = msg;
assert(ev.name == "mmi.request.start");
assert(ev.data.compound["foo"] == 12);
assert(ev.origin == msg.source);
-
+
}
-
-
+
+
{
// --- StartResponse
std::stringstream ss;
@@ -516,7 +516,7 @@ int main(int argc, char** argv) {
Event ev = msg;
assert(ev.name == "mmi.response.pause");
assert(ev.origin == msg.source);
-
+
}
{
@@ -624,7 +624,7 @@ int main(int argc, char** argv) {
assert(boost::iequals(msg.requestId, "request-1"));
assert(boost::iequals(msg.context, "someURI"));
assert(boost::iequals(msg.name, "appEvent"));
-
+
ExtensionNotification msg2 = ExtensionNotification::fromXML(msg.toXML());
assert(boost::iequals(msg2.tagName, "ExtensionNotification"));
assert(boost::iequals(msg2.source, "someURI"));
@@ -632,18 +632,18 @@ int main(int argc, char** argv) {
assert(boost::iequals(msg2.requestId, "request-1"));
assert(boost::iequals(msg2.context, "someURI"));
assert(boost::iequals(msg2.name, "appEvent"));
-
+
std::stringstream xml1SS;
std::stringstream xml2SS;
xml1SS << msg.toXML();
xml2SS << msg2.toXML();
assert(xml1SS.str() == xml2SS.str());
-
+
Event ev = msg;
assert(ev.name == "appEvent");
assert(ev.data.compound["foo"] == 12);
assert(ev.origin == msg.source);
-
+
}
{
diff --git a/test/src/test-promela-parser.cpp b/test/src/test-promela-parser.cpp
index 61e6b3f..261b8c9 100644
--- a/test/src/test-promela-parser.cpp
+++ b/test/src/test-promela-parser.cpp
@@ -165,8 +165,6 @@ void testInlinePromela() {
assert(prmInls.inlines.front().sequences.size() == 0);
assert(boost::trim_copy(prmInls.inlines.front().content) == "This is foo!");
}
-
- exit(0);
}
void testPromelaParser() {
@@ -188,6 +186,18 @@ void testPromelaParser() {
expressions.push_back("bool busy[3];");
expressions.push_back("bool busy[3], us[4];");
expressions.push_back("mtype = {\nred, white, blue,\nabort, accept, ack, sync_ack, close, connect,\ncreate, data, eof, open, reject, sync, transfer,\nFATAL, NON_FATAL, COMPLETE\n}");
+ expressions.push_back("typedef D { short f; byte g }; ");
+ expressions.push_back("x = 1");
+ expressions.push_back("x = foo.bar[2].baz; ");
+ expressions.push_back("_event.data[1].aParam.key1.key2[1].key3.key4");
+ expressions.push_back("_event.data.aParam");
+ expressions.push_back("_event.data");
+ expressions.push_back("_event");
+ expressions.push_back("states");
+ expressions.push_back("states[1]");
+ expressions.push_back("_x.states[1]");
+ expressions.push_back("_x.states[1].foo");
+ expressions.push_back("_event.data[1].aParam.key1.key2[1].key3.key4");
/* expressions */
expressions.push_back("i+1");
@@ -203,8 +213,8 @@ void testPromelaParser() {
expressions.push_back("c++");
expressions.push_back("state = state - 1");
expressions.push_back("printf(\"hello world\\n\")");
- expressions.push_back("printf(\"result %d: %d\n\", id, res, foo, bar)");
- expressions.push_back("printf(\"x = %d\n\", x)");
+ expressions.push_back("printf(\"result %d: %d\\n\", id, res, foo, bar)");
+ expressions.push_back("printf(\"x = %d\\n\", x)");
expressions.push_back("(n <= 1)");
expressions.push_back("res = (a*a+b)/2*a;");
expressions.push_back("assert(0) /* a forced stop, (Chapter 6) */");
diff --git a/test/src/test-sockets.cpp b/test/src/test-sockets.cpp
index 993aaff..16234ee 100644
--- a/test/src/test-sockets.cpp
+++ b/test/src/test-sockets.cpp
@@ -74,10 +74,10 @@ int main(int argc, char** argv) {
// LogServer server(PF_INET, SOCK_STREAM, 0);
server.listen("*", 1235);
server.setBlockSizeRead(1);
-
+
TestClient client(PF_INET, SOCK_STREAM, 0);
client.connect("127.0.0.1", 1235);
-
+
int iterations = 1000;
std::stringstream contentSS;
for (int i = 0; i < iterations; i++) {
@@ -94,7 +94,7 @@ int main(int argc, char** argv) {
packetSeq = 0;
CountingPacketServer server(PF_INET, SOCK_STREAM, 0, std::string("\0", 1));
server.listen("*", 1235);
-
+
TestClient client(PF_INET, SOCK_STREAM, 0);
client.connect("127.0.0.1", 1235);
@@ -107,9 +107,9 @@ int main(int argc, char** argv) {
while(packetSeq != iterations)
tthread::this_thread::sleep_for(tthread::chrono::milliseconds(20));
}
-
+
exit(0);
-
+
if (1) {
// start server socket and connect
int iterations = 100;
diff --git a/test/src/test-url.cpp b/test/src/test-url.cpp
index b3f9e28..5e5f4ea 100644
--- a/test/src/test-url.cpp
+++ b/test/src/test-url.cpp
@@ -49,7 +49,7 @@ int main(int argc, char** argv) {
#endif
HTTPServer::getInstance(8099, 8100);
-
+
std::string exeName = argv[0];
exeName = exeName.substr(exeName.find_last_of("\\/") + 1);
diff --git a/test/src/test-vxml-mmi-http.cpp b/test/src/test-vxml-mmi-http.cpp
index 2b2cd25..35dc5d6 100644
--- a/test/src/test-vxml-mmi-http.cpp
+++ b/test/src/test-vxml-mmi-http.cpp
@@ -50,28 +50,29 @@ public:
bool httpRecvRequest(const HTTPServer::Request& request) {
std::cout << "RCVD:" << std::endl << request << std::flush;
tthread::lock_guard<tthread::mutex> lock(Mutex);
-
+
const Arabica::DOM::Document<std::string>& doc = request.data.at("content").node.getOwnerDocument();
// NameSpacingParser parser = NameSpacingParser::fromXML(request.content);
switch(MMIEvent::getType(doc.getDocumentElement())) {
- case MMIEvent::NEWCONTEXTRESPONSE: {
- NewContextResponse* resp = new NewContextResponse(NewContextResponse::fromXML(doc.getDocumentElement()));
- context = resp->context;
- Replies[resp->requestId] = resp;
- break;
- }
- case MMIEvent::STARTRESPONSE: {
- StartResponse* resp = new StartResponse(StartResponse::fromXML(doc.getDocumentElement()));
- Replies[resp->requestId] = resp;
- }
- default: ;
+ case MMIEvent::NEWCONTEXTRESPONSE: {
+ NewContextResponse* resp = new NewContextResponse(NewContextResponse::fromXML(doc.getDocumentElement()));
+ context = resp->context;
+ Replies[resp->requestId] = resp;
+ break;
+ }
+ case MMIEvent::STARTRESPONSE: {
+ StartResponse* resp = new StartResponse(StartResponse::fromXML(doc.getDocumentElement()));
+ Replies[resp->requestId] = resp;
+ }
+ default:
+ ;
}
-
+
Cond.notify_all();
-
+
HTTPServer::Reply reply(request);
HTTPServer::reply(reply);
-
+
return true;
}
void setURL(const std::string& url) {
@@ -86,7 +87,7 @@ void printUsageAndExit(const char* progName) {
if (progStr.find_last_of(PATH_SEPERATOR) != std::string::npos) {
progStr = progStr.substr(progStr.find_last_of(PATH_SEPERATOR) + 1, progStr.length() - (progStr.find_last_of(PATH_SEPERATOR) + 1));
}
-
+
printf("%s version " USCXML_VERSION " (" CMAKE_BUILD_TYPE " build - " CMAKE_COMPILER_STRING ")\n", progStr.c_str());
printf("Usage\n");
printf("\t%s", progStr.c_str());
@@ -105,26 +106,26 @@ int main(int argc, char** argv) {
std::string target;
std::string document;
-
+
if (argc < 2)
printUsageAndExit(argv[0]);
int option;
while ((option = getopt(argc, argv, "t:")) != -1) {
switch(option) {
- case 't':
- target = optarg;
- break;
- default:
- printUsageAndExit(argv[0]);
+ case 't':
+ target = optarg;
+ break;
+ default:
+ printUsageAndExit(argv[0]);
}
}
-
+
if (argc < optind)
printUsageAndExit(argv[0]);
-
+
document = argv[optind];
-
+
if (!boost::starts_with(document, "http"))
document = "http://" + document;
@@ -134,11 +135,11 @@ int main(int argc, char** argv) {
// target = "http://130.83.163.167:9090/mmi";
// target = "http://localhost:9090/mmi";
-
+
MMIServlet servlet;
HTTPServer::getInstance(4344, 0);
HTTPServer::getInstance()->registerServlet("/mmi", &servlet);
-
+
std::string source = servlet.url;
NewContextRequest newCtxReq;
@@ -147,12 +148,12 @@ int main(int argc, char** argv) {
newCtxReq.requestId = uscxml::UUID::getUUID();
Requests[newCtxReq.requestId] = &newCtxReq;
-
+
ISSUE_REQUEST(newCtxReq, false);
while(Replies.find(newCtxReq.requestId) == Replies.end())
Cond.wait(Mutex);
-
+
StartRequest startReq;
startReq.context = context;
startReq.source = source;
@@ -160,7 +161,7 @@ int main(int argc, char** argv) {
startReq.requestId = uscxml::UUID::getUUID();
startReq.contentURL.href = document;
//"https://raw.githubusercontent.com/Roland-Taizun-Azhar/TaskAssistance-Project/master/WebContent/hello.vxml";
-
+
Requests[startReq.requestId] = &startReq;
ISSUE_REQUEST(startReq, false);
@@ -173,6 +174,6 @@ int main(int argc, char** argv) {
} catch (std::exception e) {
std::cout << e.what() << std::endl;
}
-
-
+
+
} \ No newline at end of file
diff --git a/test/src/test-vxml-mmi-socket.cpp b/test/src/test-vxml-mmi-socket.cpp
index 99662c9..4db7109 100644
--- a/test/src/test-vxml-mmi-socket.cpp
+++ b/test/src/test-vxml-mmi-socket.cpp
@@ -23,18 +23,18 @@ bool testAddressParsing() {
std::string protocol;
std::string hostName;
uint16_t port;
-
+
{
Socket::parseAddress("4343", protocol, hostName, port);
assert(protocol == "tcp");
assert(hostName == "127.0.0.1");
assert(port == 4343);
-
+
Socket::parseAddress("localhost:4343", protocol, hostName, port);
assert(protocol == "tcp");
assert(hostName == "localhost");
assert(port == 4343);
-
+
Socket::parseAddress("tcp://localhost:4343", protocol, hostName, port);
assert(protocol == "tcp");
assert(hostName == "localhost");
@@ -52,16 +52,16 @@ bool testMMIEvents() {
Arabica::DOM::Document<std::string> newCtxReqXML1 = newCtxReq.toXML();
Arabica::DOM::Document<std::string> newCtxReqXML2 = newCtxReq.toXML(true);
-
+
// std::cout << newCtxReqXML1 << std::endl;
// std::cout << newCtxReqXML2 << std::endl;
-
+
NewContextRequest newCtxReq1 = NewContextRequest::fromXML(newCtxReqXML1.getDocumentElement());
NewContextRequest newCtxReq2 = NewContextRequest::fromXML(newCtxReqXML2.getDocumentElement());
-
+
assert(MMIEvent::getType(newCtxReqXML1.getDocumentElement()) == MMIEvent::NEWCONTEXTREQUEST);
assert(MMIEvent::getType(newCtxReqXML2.getDocumentElement()) == MMIEvent::NEWCONTEXTREQUEST);
-
+
assert(newCtxReq1.source == "localhost:3434");
assert(newCtxReq2.source == "localhost:3434");
assert(newCtxReq1.target == "localhost:1212");
@@ -109,28 +109,28 @@ int main(int argc, char** argv) {
#endif
testAddressParsing();
testMMIEvents();
-
+
// TestClient client(PF_INET, SOCK_STREAM, 0);
// client.connect("epikur.local", 4343);
std::string target = "localhost:4343";
std::string source = "localhost:4344";
-
+
TestServer server(PF_INET, SOCK_STREAM, 0);
server.listen(source);
-
+
// while(true)
// sleep(1000);
-
+
TestClient client(PF_INET, SOCK_STREAM, 0);
client.connect(source);
-
+
NewContextRequest newCtxReq;
newCtxReq.source = source;
newCtxReq.target = target;
newCtxReq.requestId = UUID::getUUID();
-
+
_requests[newCtxReq.requestId] = &newCtxReq;
-
+
Arabica::DOM::Document<std::string> newCtxReqXML = newCtxReq.toXML(true);
std::stringstream newCtxReqXMLSS;
newCtxReqXMLSS << newCtxReqXML;
@@ -141,7 +141,7 @@ int main(int argc, char** argv) {
// client.write(newCtxReqXMLSS.str().data(), newCtxReqXMLSS.str().size());
// client.write("\0", 1);
}
-
+
while(true)
sleep(1000);
diff --git a/test/src/test-w3c.cpp b/test/src/test-w3c.cpp
index 3c20e76..27c69b2 100644
--- a/test/src/test-w3c.cpp
+++ b/test/src/test-w3c.cpp
@@ -98,10 +98,10 @@ int main(int argc, char** argv) {
using namespace uscxml;
try {
-
- #if defined(HAS_SIGNAL_H) && !defined(WIN32)
+
+#if defined(HAS_SIGNAL_H) && !defined(WIN32)
signal(SIGPIPE, SIG_IGN);
- #endif
+#endif
if (argc < 2) {
exit(EXIT_FAILURE);
@@ -116,23 +116,23 @@ int main(int argc, char** argv) {
if (dfEnv) {
delayFactor = strTo<double>(dfEnv);
}
-
+
int option;
while ((option = getopt(argc, argv, "fd:")) != -1) {
switch(option) {
- case 'f':
- withFlattening = true;
- break;
- case 'd':
- delayFactor = strTo<double>(optarg);
- break;
- default:
- break;
+ case 'f':
+ withFlattening = true;
+ break;
+ case 'd':
+ delayFactor = strTo<double>(optarg);
+ break;
+ default:
+ break;
}
}
documentURI = argv[optind];
-
+
Interpreter interpreter;
LOG(INFO) << "Processing " << documentURI << (withFlattening ? " FSM converted" : "") << (delayFactor ? "" : " with delays *= " + toStr(delayFactor));
if (withFlattening) {
@@ -147,7 +147,7 @@ int main(int argc, char** argv) {
Arabica::DOM::Document<std::string> document = interpreter.getDocument();
Arabica::DOM::Element<std::string> root = document.getDocumentElement();
Arabica::XPath::NodeSet<std::string> sends = InterpreterImpl::filterChildElements(interpreter.getNameSpaceInfo().xmlNSPrefix + "send", root, true);
-
+
for (int i = 0; i < sends.size(); i++) {
Arabica::DOM::Element<std::string> send = Arabica::DOM::Element<std::string>(sends[i]);
if (HAS_ATTR(send, "delay")) {
@@ -161,9 +161,9 @@ int main(int argc, char** argv) {
} else if (HAS_ATTR(send, "delayexpr")) {
std::string delayExpr = ATTR(send, "delayexpr");
send.setAttribute("delayexpr",
- "(" + delayExpr + ".indexOf('ms', " + delayExpr + ".length - 2) !== -1 ? "
- "(" + delayExpr + ".slice(0,-2) * " + toStr(delayFactor) + ") + \"ms\" : "
- "(" + delayExpr + ".slice(0,-1) * 1000 * " + toStr(delayFactor) + ") + \"ms\")");
+ "(" + delayExpr + ".indexOf('ms', " + delayExpr + ".length - 2) !== -1 ? "
+ "(" + delayExpr + ".slice(0,-2) * " + toStr(delayFactor) + ") + \"ms\" : "
+ "(" + delayExpr + ".slice(0,-1) * 1000 * " + toStr(delayFactor) + ") + \"ms\")");
std::cout << ATTR(send, "delayexpr") << std::endl;
}
}
@@ -172,7 +172,7 @@ int main(int argc, char** argv) {
std::cout << *issueIter << std::endl;
}
}
-
+
if (interpreter) {
W3CStatusMonitor* vm = new W3CStatusMonitor();
interpreter.addMonitor(vm);