summaryrefslogtreecommitdiff
path: root/slicer/test/preprocessor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'slicer/test/preprocessor.cpp')
-rw-r--r--slicer/test/preprocessor.cpp84
1 files changed, 53 insertions, 31 deletions
diff --git a/slicer/test/preprocessor.cpp b/slicer/test/preprocessor.cpp
index fadbac9..7431a2d 100644
--- a/slicer/test/preprocessor.cpp
+++ b/slicer/test/preprocessor.cpp
@@ -2,27 +2,69 @@
#include <boost/test/unit_test.hpp>
#include <tool/parser.h>
+#include <common.h>
#include <boost/format.hpp>
#include <buffer.h>
+#include <definedDirs.h>
#include "helpers.h"
-#include "fileStructure.h"
namespace fs = boost::filesystem;
-const unsigned int COMPONENTS_IN_TEST_ICE = 40;
+typedef std::map<std::string, unsigned int> ComponentsCount;
+ComponentsCount COMPONENTS_IN_TEST_ICE = {
+ { "enums.ice", 2 },
+ { "structs.ice", 4 },
+ { "classes.ice", 4 },
+ { "optionals.ice", 1 },
+ { "collections.ice", 6 },
+ { "inheritance.ice", 12 },
+ { "interfaces.ice", 0 },
+ { "json.ice", 2 },
+ { "xml.ice", 2 },
+ { "db.ice", 4 },
+ { "types.ice", 3 }
+};
-BOOST_FIXTURE_TEST_SUITE ( preprocessor, FileStructure );
+unsigned int
+total()
+{
+ unsigned int t = 0;
+ for(const auto & c : COMPONENTS_IN_TEST_ICE) {
+ t += c.second;
+ }
+ return t;
+ BOOST_REQUIRE_EQUAL(40, t);
+}
+
+void
+process(Slicer::Slicer & s, const ComponentsCount::value_type & c)
+{
+#if BOOST_VERSION / 100 >= 1060
+ BOOST_TEST_CONTEXT(c.first)
+#endif
+ {
+ s.slicePath = rootDir / c.first;
+ BOOST_REQUIRE_EQUAL(c.second, s.Execute());
+ }
+}
+
+void
+processAll(Slicer::Slicer & s)
+{
+ s.includes.push_back(rootDir / "included");
+ s.includes.push_back(rootDir);
+ for(const auto & c : COMPONENTS_IN_TEST_ICE) {
+ BOOST_TEST_CHECKPOINT(c.first);
+ process(s, c);
+ }
+ BOOST_REQUIRE_EQUAL(total(), s.Components());
+}
BOOST_AUTO_TEST_CASE( slicer_test_counts_path )
{
Slicer::Slicer s;
- s.slicePath = slice;
s.cppPath = "/dev/null";
- s.includes.push_back(included);
-
- auto count = s.Execute();
- BOOST_REQUIRE_EQUAL(COMPONENTS_IN_TEST_ICE, count);
- BOOST_REQUIRE_EQUAL(COMPONENTS_IN_TEST_ICE, s.Components());
+ processAll(s);
}
BOOST_AUTO_TEST_CASE( slicer_test_counts_filestar )
@@ -30,34 +72,14 @@ BOOST_AUTO_TEST_CASE( slicer_test_counts_filestar )
FILE * file = fopen("/dev/null", "a");
BOOST_REQUIRE(file);
Slicer::Slicer s;
- s.slicePath = slice;
s.cpp = file;
- s.includes.push_back(included);
-
- auto count = s.Execute();
- BOOST_REQUIRE_EQUAL(COMPONENTS_IN_TEST_ICE, count);
-
+ processAll(s);
fclose(file);
}
BOOST_AUTO_TEST_CASE( slicer_test_counts_nullfilestar )
{
Slicer::Slicer s;
- s.slicePath = slice;
- s.includes.push_back(included);
-
- auto count = s.Execute();
- BOOST_REQUIRE_EQUAL(COMPONENTS_IN_TEST_ICE, count);
+ processAll(s);
}
-BOOST_AUTO_TEST_CASE( slicer_test_counts_interfacesOnly )
-{
- Slicer::Slicer s;
- s.slicePath = root / "interfaces.ice";
-
- auto count = s.Execute();
- BOOST_REQUIRE_EQUAL(0, count);
-}
-
-BOOST_AUTO_TEST_SUITE_END();
-