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

An exception case during run Base32 gtest #107

Closed
YoungSeokHong opened this issue Oct 9, 2021 · 3 comments · Fixed by #110
Closed

An exception case during run Base32 gtest #107

YoungSeokHong opened this issue Oct 9, 2021 · 3 comments · Fixed by #110
Labels

Comments

@YoungSeokHong
Copy link
Contributor

Thanks to @kuro11pow2 , I find an bug during Base32 gtest!

TestParamType(std::vector<u_int8_t>{ 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, "100000000")

It is a special case because it goes 1 00000000000000000000 00000000000000000000. And when 00000000000000000000 enters the bitsToBase32 function, nothing happens because of the condition of while loop while(value != 0).

The best way I think is to add exception code to catch 00000000000000000000input case.

if(!value)result = "0000";

Because it is an unusual case.

I'm really appreciate to 'kuro11pow2' for making a sharp test case.
Please give me some solution or I'll make PR with my solution.

YoungSeokHong added a commit to YoungSeokHong/euphony that referenced this issue Oct 9, 2021
@kuro11pow2
Copy link
Member

It's my pleasure 😄

@kuro11pow2
Copy link
Member

I think you have found a solution to this problem. 👍
In addition, the same problem can occur in BASE64. I think this should also be corrected.

std::string Base64::bitsToBase64(int value){
std::string result;
while(value != 0) {
result = convertInt2Char(value & 0x3f) + result;
value >>= 6;
}
return result;
}

@YoungSeokHong
Copy link
Contributor Author

Thanks for your notice! I'll update Base64 too. 😀

YoungSeokHong added a commit to YoungSeokHong/euphony that referenced this issue Oct 10, 2021
YoungSeokHong added a commit to YoungSeokHong/euphony that referenced this issue Oct 10, 2021
Co-authored-by: JK Park <kuro11pow2@gmail.com>
@designe designe linked a pull request Oct 11, 2021 that will close this issue
designe pushed a commit that referenced this issue Oct 12, 2021
* Update Base32.cpp & Base64.cpp to solve #107
* Update Base32.h, Base64.h, Base32.cpp, Base64.cpp to make solution more simple

Co-authored-by: JK Park <kuro11pow2@gmail.com>
@designe designe added the bug label Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants