mirror of
https://github.com/zxing/zxing.git
synced 2024-09-20 05:27:32 -07:00
String of zero polynomial be "0" (#1020)
* String of zero polynomial be "0" * add test * add more test * modify test case
This commit is contained in:
parent
4d39673d67
commit
3778715156
|
@ -225,6 +225,9 @@ final class GenericGFPoly {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (isZero()) {
|
||||
return "0";
|
||||
}
|
||||
StringBuilder result = new StringBuilder(8 * getDegree());
|
||||
for (int degree = getDegree(); degree >= 0; degree--) {
|
||||
int coefficient = getCoefficient(degree);
|
||||
|
|
|
@ -393,6 +393,13 @@ public final class ReedSolomonTestCase extends Assert {
|
|||
testEncodeDecodeRandom(GenericGF.AZTEC_DATA_12, 3072, 1023);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPolynomialString() {
|
||||
assertEquals("0", GenericGF.QR_CODE_FIELD_256.getZero().toString());
|
||||
GenericGFPoly p = new GenericGFPoly(GenericGF.QR_CODE_FIELD_256, new int[] {3, 0, -2, 1, 1});
|
||||
assertEquals("a^25x^4 - ax^2 + x + 1", p.toString());
|
||||
}
|
||||
|
||||
public static void corrupt(int[] received, int howMany, Random random, int max) {
|
||||
BitSet corrupted = new BitSet(received.length);
|
||||
for (int j = 0; j < howMany; j++) {
|
||||
|
@ -503,4 +510,4 @@ public final class ReedSolomonTestCase extends Assert {
|
|||
return new Random(0xDEADBEEF);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue