Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed all duplicated branches in AgastKeypoint2D #2657

Merged

Conversation

SunBlack
Copy link
Contributor

Removed all duplicated branches in AgastKeypoint2D reported by CppCheck 1.85

I don't know who wrote the code, but I hope it was autogenerated code xD

Copy link
Member

@taketwo taketwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I did not read the diff, but I trust CppCheck here.

@SergioRAgostinho
Copy link
Member

There's no unit tests for this :')

@SergioRAgostinho SergioRAgostinho merged commit a884072 into PointCloudLibrary:master Nov 28, 2018
@SunBlack SunBlack deleted the remove_duplicateBranches branch November 28, 2018 19:24
@SunBlack
Copy link
Contributor Author

SunBlack commented Nov 29, 2018

I checked it now again to be sure and all is fine:

#include <array>
#include <iostream>

constexpr int offset0 = 0;
constexpr int offset1 = 1;
constexpr int offset2 = 2;
constexpr int offset3 = 3;
constexpr int offset4 = 4;
constexpr int offset5 = 5;
constexpr int offset6 = 6;
constexpr int offset7 = 7;
constexpr int offset8 = 8;
constexpr int offset9 = 9;
constexpr int offset10 = 10;
constexpr int offset11 = 11;

int cb = 1;
int c_b = 3;

bool isCorner_new(const std::array<int, 12> &p)
{
//insert new Code here
	is_a_corner:
		return true;

	is_not_a_corner:
		return false;
}

bool isCorner_old(const std::array<int, 12> &p)
{
//insert old Code here
	is_a_corner:
		return true;

	is_not_a_corner:
		return false;
}

void testIteration(std::array<int, 12> &p, int level)
{
	if (level == p.size())
	{
		if (isCorner_new(p) != isCorner_old(p))
		{
			std::cout << "Mismatch found:";
			for (auto value : p)
			{
				std::cout << " " << value;
			}
			std::cout << std::endl;
		}
		
		return;
	}

	auto nextLevel = level + 1;

	p[level] = 0;
	testIteration(p, nextLevel);

	p[level] = 2;
	testIteration(p, nextLevel);

	p[level] = 4;
	testIteration(p, nextLevel);
}

int main(int argc, char *argv[])
{
	std::array<int, 12> p;

	testIteration(p, 0);
	std::swap(cb, c_b);
	testIteration(p, 0);

	std::cout << "End";
}

@taketwo taketwo changed the title Removed all duplicated branches in AgastKeypoint2D Removed all duplicated branches in AgastKeypoint2D Jan 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants