diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2017-09-01 16:40:48 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-09-01 20:47:34 +0000 |
commit | 3c5944c93445bb40c2131ea6782e8cc8b673bffb (patch) | |
tree | f6f9db309598f7abaaa4d544782ce993b7c576e6 /fxbarcode/oned/BC_OnedEAN8Writer.cpp | |
parent | ab3c111433229fc79275c4b413b24bec6f5463ce (diff) | |
download | pdfium-3c5944c93445bb40c2131ea6782e8cc8b673bffb.tar.xz |
Add unit tests for EAN-8 barcode writer.chromium/3204
Bug: pdfium:882
Change-Id: I900d3c1b0b74523fa9e4497da65c68eb307ea6dc
Reviewed-on: https://pdfium-review.googlesource.com/12950
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxbarcode/oned/BC_OnedEAN8Writer.cpp')
-rw-r--r-- | fxbarcode/oned/BC_OnedEAN8Writer.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/fxbarcode/oned/BC_OnedEAN8Writer.cpp index 3fcb1e8350..c3becc1a43 100644 --- a/fxbarcode/oned/BC_OnedEAN8Writer.cpp +++ b/fxbarcode/oned/BC_OnedEAN8Writer.cpp @@ -86,16 +86,16 @@ CFX_WideString CBC_OnedEAN8Writer::FilterContents( int32_t CBC_OnedEAN8Writer::CalcChecksum(const CFX_ByteString& contents) { int32_t odd = 0; int32_t even = 0; + FX_STRSIZE parity = 1; for (FX_STRSIZE i = contents.GetLength(); i > 0; i--) { if (i % 2) { odd += FXSYS_DecimalCharToInt(contents[i - 1]); } else { even += FXSYS_DecimalCharToInt(contents[i - 1]); } + parity++; } - int32_t checksum = (odd * 3 + even) % 10; - checksum = (10 - checksum) % 10; - return checksum; + return (10 - (odd * 3 + even) % 10) % 10; } uint8_t* CBC_OnedEAN8Writer::EncodeWithHint(const CFX_ByteString& contents, |