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

IEP-976 Test coverage for BigIntDecoder #784

Merged
merged 2 commits into from
Jun 29, 2023
Merged

IEP-976 Test coverage for BigIntDecoder #784

merged 2 commits into from
Jun 29, 2023

Conversation

sigmaaa
Copy link
Collaborator

@sigmaaa sigmaaa commented Jun 9, 2023

Description

Added test coverage for BigIntDecoder class. Also, during the test I found bug, so I fixed it in this PR. The bug was in the incorrect decoding of hex, and octal values without a sign.

Fixes # (IEP-976)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How has this been tested?

BigIntDecoder is using for validating data in the NVS table, so to test it:

  • Open the NVS table editor
  • Add a new row
  • type some name in a new row and select 'data' as a type
  • select encoding, for example u8 and type hex/oct/dec numbers for example 0xFF - should be ok, 0xFFF - out of range for u8, FF - incorrect format

Test Configuration:

  • ESP-IDF Version:
  • OS (Windows,Linux and macOS):

Dependent components impacted by this PR:

  • NVS table editor validation input

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Added Documentation
  • Added Unit Test
  • Verified on all platforms - Windows,Linux and macOS

Copy link
Collaborator Author

@sigmaaa sigmaaa left a comment

Choose a reason for hiding this comment

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

self reviewed

@@ -45,7 +45,7 @@ else if (stringToDecode.startsWith("0", index) && stringToDecode.length() > 1 +
}

return hasSign ? new BigInteger(firstChar + stringToDecode.substring(index), radix)
: new BigInteger(stringToDecode.substring(index));
: new BigInteger(stringToDecode.substring(index), radix);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the bug was here. Without radix, we can't parse hex, oct values

Copy link
Collaborator

@alirana01 alirana01 left a comment

Choose a reason for hiding this comment

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

LGTM

@kolipakakondal kolipakakondal merged commit 36be46f into master Jun 29, 2023
Copy link
Collaborator

@kolipakakondal kolipakakondal left a comment

Choose a reason for hiding this comment

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

LGTM

@kolipakakondal kolipakakondal deleted the IEP-976 branch June 29, 2023 05:40
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.

3 participants