1313#include < model/cppfunction-odb.hxx>
1414#include < model/cppastnodemetrics.h>
1515#include < model/cppastnodemetrics-odb.hxx>
16+ #include < model/cppfilemetrics.h>
17+ #include < model/cppfilemetrics-odb.hxx>
1618
1719#include < util/dbutil.h>
1820#include < util/odbtransaction.h>
@@ -21,6 +23,8 @@ using namespace cc;
2123
2224extern char * dbConnectionString;
2325
26+ typedef std::pair<std::string, unsigned int > StringUintParam;
27+
2428class CppMetricsParserTest : public ::testing::Test
2529{
2630public:
@@ -62,14 +66,12 @@ bool CppMetricsParserTest::queryRecordMetric(
6266
6367// McCabe
6468
65- typedef std::pair<std::string, unsigned int > McCabeParam;
66-
6769class ParameterizedMcCabeTest
6870 : public CppMetricsParserTest,
69- public ::testing::WithParamInterface<McCabeParam >
71+ public ::testing::WithParamInterface<StringUintParam >
7072{};
7173
72- std::vector<McCabeParam > paramMcCabe = {
74+ std::vector<StringUintParam > paramMcCabe = {
7375 {" conditionals" , 8 },
7476 {" loops1" , 6 },
7577 {" loops2" , 6 },
@@ -173,10 +175,10 @@ INSTANTIATE_TEST_SUITE_P(
173175
174176class ParameterizedTypeMcCabeTest
175177 : public CppMetricsParserTest,
176- public ::testing::WithParamInterface<McCabeParam >
178+ public ::testing::WithParamInterface<StringUintParam >
177179{};
178180
179- std::vector<McCabeParam > paramTypeMcCabe = {
181+ std::vector<StringUintParam > paramTypeMcCabe = {
180182 {" Empty" , 0 },
181183 {" ClassMethodsInside" , 16 },
182184 {" ClassMethodsOutside" , 44 },
@@ -271,13 +273,12 @@ INSTANTIATE_TEST_SUITE_P(
271273
272274// Afferent coupling
273275
274- typedef std::pair<std::string, unsigned int > AfferentParam;
275276class ParameterizedAfferentCouplingTest
276277 : public CppMetricsParserTest,
277- public ::testing::WithParamInterface<AfferentParam >
278+ public ::testing::WithParamInterface<StringUintParam >
278279{};
279280
280- std::vector<AfferentParam > paramAfferent = {
281+ std::vector<StringUintParam > paramAfferent = {
281282 {" A" , 1 },
282283 {" A2" , 1 },
283284 {" A3" , 1 },
@@ -320,3 +321,35 @@ INSTANTIATE_TEST_SUITE_P(
320321 ParameterizedAfferentCouplingTest,
321322 ::testing::ValuesIn (paramAfferent)
322323);
324+
325+ // Efferent coupling at module level
326+
327+ class ParameterizedEfferentModuleCouplingTest
328+ : public CppMetricsParserTest,
329+ public ::testing::WithParamInterface<StringUintParam>
330+ {};
331+
332+ std::vector<StringUintParam> paramEfferentModule = {
333+ {" %/test/sources/parser/module_a" , 1 },
334+ {" %/test/sources/parser/module_b" , 0 },
335+ {" %/test/sources/parser/module_c" , 2 },
336+ };
337+
338+ TEST_P (ParameterizedEfferentModuleCouplingTest, ModuleEfferentTest) {
339+ _transaction ([&, this ]() {
340+
341+ typedef odb::query<model::CppModuleMetricsForPathView> CppModuleMetricsQuery;
342+
343+ const auto metric = _db->query_value <model::CppModuleMetricsForPathView>(
344+ CppModuleMetricsQuery::CppFileMetrics::type == model::CppFileMetrics::Type::EFFERENT_MODULE &&
345+ CppModuleMetricsQuery::File::path.like (GetParam ().first ));
346+
347+ EXPECT_EQ (GetParam ().second , metric.value );
348+ });
349+ }
350+
351+ INSTANTIATE_TEST_SUITE_P (
352+ ParameterizedEfferentModuleCouplingTestSuite,
353+ ParameterizedEfferentModuleCouplingTest,
354+ ::testing::ValuesIn (paramEfferentModule)
355+ );
0 commit comments