8000 Expand decoder tests and improve handling of variable-sized uints by oschwald · Pull Request #227 · runk/mmdb-lib · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Expand decoder tests and improve handling of variable-sized uints #227

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

Merged
merged 3 commits into from
May 2, 2025

Conversation

oschwald
Copy link
Collaborator
  • test: increase decoding coverage for all types
  • fix: correct handling of large uints

This should cover all the major edge cases when decoding the data
section.
Previously, we were not correctly handling variable-sized uints.
@oschwald oschwald force-pushed the greg/more-decoder-tests branch from 5b32d92 to 293091e Compare April 30, 2025 19:43
@runk
Copy link
Owner
runk commented Apr 30, 2025

Looking good, left a comment which is more of a nit - feel free to ignore it if you like

@@ -277,7 +277,7 @@ export default class Decoder {
return this.db.readUIntBE(offset, size);
}
if (size == 8) {
return this.db.readBigInt64BE(offset).toString();
return this.db.readBigUInt64BE(offset).toString();
Copy link
Owner

Choose a reason for hiding this comment

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

👍

];

for (const tc of testCases) {
const inputStr =
Copy link
Owner

Choose a reason for hiding this comment

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

This is used a bunch of times - maybe a worthwhile making a small helper fn for it. Same for expectedStr.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks. I did that for the three inputStr uses. For expectedStr, the two uses are different as one is for a string and the other is for a Buffer.

@oschwald oschwald merged commit ae84e9e into runk:master May 2, 2025
4 checks passed
@oschwald oschwald deleted the greg/more-decoder-tests branch May 2, 2025 01:57
Copy link
github-actions bot commented May 2, 2025

🎉 This PR is included in version 2.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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 this pull request may close these issues.

2 participants
0