diff --git a/plugins/cpp_metrics/test/sources/parser/typemccabe.cpp b/plugins/cpp_metrics/test/sources/parser/typemccabe.cpp index d1d2b3d50..d7c5da383 100644 --- a/plugins/cpp_metrics/test/sources/parser/typemccabe.cpp +++ b/plugins/cpp_metrics/test/sources/parser/typemccabe.cpp @@ -133,3 +133,13 @@ int ClassMethodsInsideAndOutside::baz() // +1 } } // 2 +bool ClassWithInnerClass::bar(bool b1, bool b2) // +1 +{ + return b1 || b2; // +1 +} // 2 + +bool ClassWithInnerClass::InnerClass::bar(bool b1, bool b2) // +1 +{ + return b1 || b2; // +1 +} // 2 + diff --git a/plugins/cpp_metrics/test/sources/parser/typemccabe.h b/plugins/cpp_metrics/test/sources/parser/typemccabe.h index 981192303..71e0b79f7 100644 --- a/plugins/cpp_metrics/test/sources/parser/typemccabe.h +++ b/plugins/cpp_metrics/test/sources/parser/typemccabe.h @@ -81,5 +81,19 @@ class ClassMethodsInsideAndOutside { int baz(); // 2 (defined in typemccabe.cpp) }; // 8 +class ClassWithInnerClass { + void foo() // +1 + { + for (int i=0; i<3; ++i) {} // +1 + } // 2 + + bool bar(bool b1, bool b2); // 2 (defined in typemccabe.cpp) + + class InnerClass { + int foo() { return 42; } // 1 + bool bar(bool b1, bool b2); // 2 (defined in typemccabe.cpp) + }; // 3 +}; // 4 + #endif // TYPE_MCCABE__H diff --git a/plugins/cpp_metrics/test/sources/service/typemccabe.cpp b/plugins/cpp_metrics/test/sources/service/typemccabe.cpp index d1d2b3d50..d7c5da383 100644 --- a/plugins/cpp_metrics/test/sources/service/typemccabe.cpp +++ b/plugins/cpp_metrics/test/sources/service/typemccabe.cpp @@ -133,3 +133,13 @@ int ClassMethodsInsideAndOutside::baz() // +1 } } // 2 +bool ClassWithInnerClass::bar(bool b1, bool b2) // +1 +{ + return b1 || b2; // +1 +} // 2 + +bool ClassWithInnerClass::InnerClass::bar(bool b1, bool b2) // +1 +{ + return b1 || b2; // +1 +} // 2 + diff --git a/plugins/cpp_metrics/test/sources/service/typemccabe.h b/plugins/cpp_metrics/test/sources/service/typemccabe.h index e4c906bd2..71e0b79f7 100644 --- a/plugins/cpp_metrics/test/sources/service/typemccabe.h +++ b/plugins/cpp_metrics/test/sources/service/typemccabe.h @@ -73,13 +73,27 @@ class ClassMethodsInsideAndOutside { } } // 3 - bool bar(bool b1, bool b2, bool b3) + bool bar(bool b1, bool b2, bool b3) // +1 { return b1 && b2 && b3; // +2 + } // 3 + + int baz(); // 2 (defined in typemccabe.cpp) +}; // 8 + +class ClassWithInnerClass { + void foo() // +1 + { + for (int i=0; i<3; ++i) {} // +1 } // 2 - int baz(); // 2 defined in typemccabe.cpp -}; // 7 + bool bar(bool b1, bool b2); // 2 (defined in typemccabe.cpp) + + class InnerClass { + int foo() { return 42; } // 1 + bool bar(bool b1, bool b2); // 2 (defined in typemccabe.cpp) + }; // 3 +}; // 4 #endif // TYPE_MCCABE__H diff --git a/plugins/cpp_metrics/test/src/cppmetricsparsertest.cpp b/plugins/cpp_metrics/test/src/cppmetricsparsertest.cpp index 5c90e2784..b4ad0b072 100644 --- a/plugins/cpp_metrics/test/src/cppmetricsparsertest.cpp +++ b/plugins/cpp_metrics/test/src/cppmetricsparsertest.cpp @@ -105,10 +105,12 @@ class ParameterizedTypeMcCabeTest {}; std::vector paramTypeMcCabe = { - {"Empty", 0}, // 0 means metric must not be present - {"ClassMethodsInside", 16}, - {"ClassMethodsOutside", 44}, - {"ClassMethodsInsideAndOutside", 8}, + {"Empty", 0}, + {"ClassMethodsInside", 16}, + {"ClassMethodsOutside", 44}, + {"ClassMethodsInsideAndOutside", 8}, + {"ClassWithInnerClass", 4}, + {"ClassWithInnerClass::InnerClass", 3}, }; TEST_P(ParameterizedTypeMcCabeTest, TypeMcCabeTest) {