[Scummvm-cvs-logs] SF.net SVN: scummvm:[50570] tools/branches/gsoc2010-decompiler/decompiler/ test/cfg_test.h

pidgeot at users.sourceforge.net pidgeot at users.sourceforge.net
Thu Jul 1 23:39:08 CEST 2010


Revision: 50570
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50570&view=rev
Author:   pidgeot
Date:     2010-07-01 21:39:07 +0000 (Thu, 01 Jul 2010)

Log Message:
-----------
Correct CFG tests to do proper vertex checking

Modified Paths:
--------------
    tools/branches/gsoc2010-decompiler/decompiler/test/cfg_test.h

Modified: tools/branches/gsoc2010-decompiler/decompiler/test/cfg_test.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/test/cfg_test.h	2010-07-01 21:08:38 UTC (rev 50569)
+++ tools/branches/gsoc2010-decompiler/decompiler/test/cfg_test.h	2010-07-01 21:39:07 UTC (rev 50570)
@@ -42,22 +42,25 @@
 		Graph g = c->getGraph();
 		TS_ASSERT(boost::num_vertices(g) == 4);
 		std::pair<VertexIterator, VertexIterator> range = boost::vertices(g);
-		VertexIterator it = range.first;
-		Group *gr = GET(*it);
-		TS_ASSERT(gr->_start->_address == 0);
-		TS_ASSERT(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 1);
-		++it;
-		gr = GET(*it);
-		TS_ASSERT(gr->_start->_address == 2);
-		TS_ASSERT(boost::in_degree(*it, g) == 1 && boost::out_degree(*it, g) == 1);
-		++it;
-		gr = GET(*it);
-		TS_ASSERT(gr->_start->_address == 5);
-		TS_ASSERT(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 1);
-		++it;
-		gr = GET(*it);
-		TS_ASSERT(gr->_start->_address == 6);
-		TS_ASSERT(boost::in_degree(*it, g) == 2 && boost::out_degree(*it, g) == 0);
+		for (VertexIterator it = range.first; it != range.second; ++it) {
+			Group *gr = GET(*it);
+			switch (gr->_start->_address) {
+			case 0:
+				TS_ASSERT(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 1);
+				break;
+			case 2:
+				TS_ASSERT(boost::in_degree(*it, g) == 1 && boost::out_degree(*it, g) == 1);
+				break;
+			case 5:
+				TS_ASSERT(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 1);
+				break;
+			case 6:
+				TS_ASSERT(boost::in_degree(*it, g) == 2 && boost::out_degree(*it, g) == 0);
+				break;
+			default:
+				TS_ASSERT(false);
+			}
+		}
 	};
 
 	void testBranching() {
@@ -70,22 +73,25 @@
 		Graph g = c->getGraph();
 		TS_ASSERT(boost::num_vertices(g) == 4);
 		std::pair<VertexIterator, VertexIterator> range = boost::vertices(g);
-		VertexIterator it = range.first;
-		Group *gr = GET(*it);
-		TS_ASSERT(gr->_start->_address == 0);
-		TS_ASSERT(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 1);
-		++it;
-		gr = GET(*it);
-		TS_ASSERT(gr->_start->_address == 2);
-		TS_ASSERT(boost::in_degree(*it, g) == 1 && boost::out_degree(*it, g) == 2);
-		++it;
-		gr = GET(*it);
-		TS_ASSERT(gr->_start->_address == 5);
-		TS_ASSERT(boost::in_degree(*it, g) == 1 && boost::out_degree(*it, g) == 1);
-		++it;
-		gr = GET(*it);
-		TS_ASSERT(gr->_start->_address == 6);
-		TS_ASSERT(boost::in_degree(*it, g) == 2 && boost::out_degree(*it, g) == 0);
+		for (VertexIterator it = range.first; it != range.second; ++it) {
+			Group *gr = GET(*it);
+			switch (gr->_start->_address) {
+			case 0:
+				TS_ASSERT(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 1);
+				break;
+			case 2:
+				TS_ASSERT(boost::in_degree(*it, g) == 1 && boost::out_degree(*it, g) == 2);
+				break;
+			case 5:
+				TS_ASSERT(boost::in_degree(*it, g) == 1 && boost::out_degree(*it, g) == 1);
+				break;
+			case 6:
+				TS_ASSERT(boost::in_degree(*it, g) == 2 && boost::out_degree(*it, g) == 0);
+				break;
+			default:
+				TS_ASSERT(false);
+			}
+		}
 	}
 
 	void testGrouping() {
@@ -99,19 +105,25 @@
 		Graph g = c->getGraph();
 		TS_ASSERT(boost::num_vertices(g) == 3);
 		std::pair<VertexIterator, VertexIterator> range = boost::vertices(g);
-		VertexIterator it = range.first;
-		Group *gr = GET(*it);
-		TS_ASSERT(gr->_start->_address == 0);
-		TS_ASSERT(gr->_end->_address == 2);		
-		TS_ASSERT(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 2);
-		++it;
-		gr = GET(*it);
-		TS_ASSERT(gr->_start->_address == 5);
-		TS_ASSERT(boost::in_degree(*it, g) == 1 && boost::out_degree(*it, g) == 1);
-		++it;
-		gr = GET(*it);
-		TS_ASSERT(gr->_start->_address == 6);
-		TS_ASSERT(boost::in_degree(*it, g) == 2 && boost::out_degree(*it, g) == 0);
+		for (VertexIterator it = range.first; it != range.second; ++it)
+		{
+			Group *gr = GET(*it);
+			switch (gr->_start->_address) {
+			case 0:
+				TS_ASSERT(gr->_end->_address == 2);		
+				TS_ASSERT(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 2);
+				break;
+			case 5:
+				TS_ASSERT(boost::in_degree(*it, g) == 1 && boost::out_degree(*it, g) == 1);
+				break;
+			case 6:
+				TS_ASSERT(boost::in_degree(*it, g) == 2 && boost::out_degree(*it, g) == 0);
+				break;
+			default:
+				TS_ASSERT(false);
+				break;
+			}
+		}
 	}
 
 	void testShortCircuitDetection() {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list