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

fix for #220 bcd length encoding #221

Closed
wants to merge 3 commits into from
Closed

fix for #220 bcd length encoding #221

wants to merge 3 commits into from

Conversation

ddvk
Copy link

@ddvk ddvk commented Apr 7, 2023

Here's is my proposition for fixing the bcd length encoding. This also fixes the variable encoding where an odd length was encoded with the next even number.

The problem I had with bcd is that there is no way to find out whether the length of original data was odd or even, that's why the Encoder interface, Encode return type change.

I couldn't come up with a more elegant solution.

@ddvk ddvk requested a review from alovak as a code owner April 7, 2023 05:34
@adamdecaf
Copy link
Member

Thanks for opening this PR! Can you update the godoc comments to mention what that integer represents?

@ddvk
Copy link
Author

ddvk commented Apr 8, 2023

the godoc of the Encode method?

@adamdecaf
Copy link
Member

Yep, thanks.

@adamdecaf
Copy link
Member

cc @alovak

Can we fix and amend that typo? @ddvk

@codecov-commenter
Copy link

Codecov Report

Patch coverage: 93.47% and project coverage change: +0.01 🎉

Comparison is base (79404f0) 73.18% compared to head (4c3426a) 73.19%.

❗ Current head 4c3426a differs from pull request most recent head c55f697. Consider uploading reports for the commit c55f697 to get more accurate results

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #221      +/-   ##
==========================================
+ Coverage   73.18%   73.19%   +0.01%     
==========================================
  Files          41       41              
  Lines        1995     1996       +1     
==========================================
+ Hits         1460     1461       +1     
  Misses        326      326              
  Partials      209      209              
Impacted Files Coverage Δ
encoding/binary.go 30.00% <0.00%> (ø)
encoding/ebcdic1047.go 76.47% <66.66%> (ø)
encoding/ascii.go 89.47% <100.00%> (ø)
encoding/bcd.go 100.00% <100.00%> (ø)
encoding/bertlv.go 90.90% <100.00%> (-0.40%) ⬇️
encoding/ebcdic.go 100.00% <100.00%> (ø)
encoding/hex.go 87.09% <100.00%> (ø)
encoding/lbcd.go 100.00% <100.00%> (ø)
field/binary.go 60.67% <100.00%> (ø)
field/bitmap.go 74.19% <100.00%> (ø)
... and 11 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@alovak alovak left a comment

Choose a reason for hiding this comment

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

I'm not sure that there is an issue with BCD encoding and prefixes. In the issue #220 specified length does not match the length of the value that is set to the field. Here is my comment about it: #220 (comment)

Maybe, we should add length validation to avoid such issues (#58).

@alovak
Copy link
Contributor

alovak commented May 10, 2023

@ddvk thanks for raising the issue and your contributions. You helped us to realize that there is an issue with field packing/unpacking. I'm closing this PR as the issue is going to be addressed by this PR: #227

@alovak alovak closed this May 10, 2023
@ddvk
Copy link
Author

ddvk commented May 10, 2023

sure, thanks a lot.

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.

4 participants