Skip to content

Commit

Permalink
Added some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Seeker04 committed Apr 13, 2024
1 parent 9b9771c commit 2216b48
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 7 deletions.
10 changes: 10 additions & 0 deletions plugins/cpp_metrics/test/sources/parser/typemccabe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

14 changes: 14 additions & 0 deletions plugins/cpp_metrics/test/sources/parser/typemccabe.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

10 changes: 10 additions & 0 deletions plugins/cpp_metrics/test/sources/service/typemccabe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

20 changes: 17 additions & 3 deletions plugins/cpp_metrics/test/sources/service/typemccabe.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

10 changes: 6 additions & 4 deletions plugins/cpp_metrics/test/src/cppmetricsparsertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ class ParameterizedTypeMcCabeTest
{};

std::vector<McCabeParam> 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) {
Expand Down

0 comments on commit 2216b48

Please sign in to comment.