summaryrefslogtreecommitdiffstats
path: root/test/src/test-flat-stateid.cpp
blob: 719e4ee213e65b03aa947e7ea15ae84179e7a9f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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:{}";
		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};visited:{s1,s2}";
		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};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");
		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);
	}
}