diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-08-04 21:39:39 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-08-04 21:39:39 (GMT) |
commit | 83ef70ebc7527240f56e2e601777a613bce6e47e (patch) | |
tree | c520fec5b446672b69353a0b37460631840b4219 /test/src | |
parent | 932916f952f302a46e41841ccf95ec1b7851b302 (diff) | |
download | uscxml-83ef70ebc7527240f56e2e601777a613bce6e47e.zip uscxml-83ef70ebc7527240f56e2e601777a613bce6e47e.tar.gz uscxml-83ef70ebc7527240f56e2e601777a613bce6e47e.tar.bz2 |
Beautified flattened state-machine ids
Diffstat (limited to 'test/src')
-rw-r--r-- | test/src/test-flat-stateid.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/src/test-flat-stateid.cpp b/test/src/test-flat-stateid.cpp new file mode 100644 index 0000000..7bc826c --- /dev/null +++ b/test/src/test-flat-stateid.cpp @@ -0,0 +1,57 @@ +#include "uscxml/transform/FlatStateIdentifier.h" +#include <cassert> + +int main(int argc, char** argv) { + std::list<std::string>::const_iterator listIter; + + { + std::string stateId = "active:{};entered:{};history:{}"; + uscxml::FlatStateIdentifier flat1(stateId); + 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); + } + + { + std::string stateId = "active:{s1};entered:{s1,s2};history:{}"; + uscxml::FlatStateIdentifier flat1(stateId); + 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};entered:{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"); + assert(*listIter++ == "s2"); + + assert(flat1.getHistory().find("h1") != flat1.getHistory().end()); + listIter = flat1.getHistory().at("h1").begin(); + assert(*listIter++ == "s2"); + assert(*listIter++ == "s3"); + + uscxml::FlatStateIdentifier flat2(flat1.getActive(), flat1.getVisited(), flat1.getHistory()); + assert(flat2.getStateId() == stateId); + } +}
\ No newline at end of file |