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

Fixed an off by 1 issue related to maxmium GeneratorId. #62

Merged
merged 2 commits into from
May 26, 2024
Merged

Fixed an off by 1 issue related to maxmium GeneratorId. #62

merged 2 commits into from
May 26, 2024

Conversation

Throwy
Copy link
Contributor

@Throwy Throwy commented May 24, 2024

Max generator id was being calculated as 1 higher than the actual max. This has been corrected and the message in the exception thrown when the given generator id is invalid has been appropriately re-worded to include 0 and maxgeneratorid.

Max generator id was being calculated as 1 higher than the actual max.
This has been corrected and the message in the exception thrown when the given
generator id is invalid has been appropriately re-worded to include 0
and maxGeneratorId.
@RobThree
Copy link
Owner

RobThree commented May 24, 2024

Oh, wow, I can't believe I missed this. Would you be so kind to also include a unittest that tests for the max and max+1 cases (using an ExpectedException like here for the max+1 case) ? Maybe also add 0 and -1 so we have the positive and negative boundaries covered. If not, I'll write them myself but I'm away from now till after the weekend.

@Throwy
Copy link
Contributor Author

Throwy commented May 24, 2024

I sure can. I'll work on updating the PR today. Funnily enough, I only found this because the wording 'between' was slightly misleading and was just going to make a PR to change the wording.

public void Constructor_Throws_OnInvalidGeneratorId_Positive_MaxPlusOne()
{
var structure = new IdStructure(41, 10, 12);
var maxgeneratorid = GetMaxGeneratorId(structure);
Copy link
Owner

@RobThree RobThree May 25, 2024

Choose a reason for hiding this comment

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

Just a little nitpick: I'd hardcode this to the actual value; if there's a bug in the ("copied" or "lifted") GetMaxGeneratorId code then the bug will also be in this test. So I guess I'm saying is I'd set maxgeneratorid to 1023 here and maybe even add a little comment making clear it's related to the 10 in the IdStructure.

But, again, thanks for the PR. I can make this (tiny) change myself later when I get back if you want to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fair. I updated the PR for that

@RobThree RobThree merged commit 6e28227 into RobThree:master May 26, 2024
1 check passed
@RobThree
Copy link
Owner

I just published a new release. Thanks for your work! Much appreciated 👏 👊

@Throwy
Copy link
Contributor Author

Throwy commented May 26, 2024

Thanks and no problem! I'm excited to start using this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants