private void TestOneCase(byte[] data, int ecLength, byte[] expectResult) { byte[] result = ReedSolomonEncoder.Encode(data, ecLength, m_cacheGeneratorPoly); if (!PolynomialExtensions.isEqual(result, expectResult)) { Assert.Fail("Remainder not same. result {0}, expect {1}", result.Length, expectResult.Length); } }
private void TestOneData(byte[] test) { BitList bitList = BitListExtensions.ToBitList(test); byte[] result = bitList.ToByteArray(); if (!PolynomialExtensions.isEqual(result, test)) { Assert.Fail("Byte convert fail. result {0}, expect {1}", result[0], test[0]); } }
private void TestOneCase(int[] aCoeff, int[] bCoeff, string option, int[] expect) { GaloisField256 gfield = GaloisField256.QRCodeGaloisField; Polynomial apoly = new Polynomial(gfield, aCoeff); Polynomial bpoly = new Polynomial(gfield, bCoeff); int[] result = resultCoeff(apoly, bpoly, option); if (!PolynomialExtensions.isEqual(result, expect)) { Assert.Fail("result {0} expect {1} option {2}", result[0], expect[0], option); } }
public void PerformanceTest() { Random randomizer = new Random(); sbyte[] zxTestCase = PolynomialExtensions.GenerateSbyteArray(40, randomizer); int ecBytes = 50; byte[] testCase = PolynomialExtensions.ToByteArray(zxTestCase); Stopwatch sw = new Stopwatch(); int timesofTest = 10000; string[] timeElapsed = new string[2]; sw.Start(); GaloisField256 gf256 = GaloisField256.QRCodeGaloisField; GeneratorPolynomial generator = new GeneratorPolynomial(gf256); for (int i = 0; i < timesofTest; i++) { ReedSolomonEncoder.Encode(testCase, ecBytes, generator); } sw.Stop(); timeElapsed[0] = sw.ElapsedMilliseconds.ToString(); sw.Reset(); sw.Start(); for (int i = 0; i < timesofTest; i++) { EncoderInternal.generateECBytes(zxTestCase, ecBytes); } sw.Stop(); timeElapsed[1] = sw.ElapsedMilliseconds.ToString(); Assert.Pass("ReedSolomon performance {0} Tests~ QrCode.Net: {1} ZXing: {2}", timesofTest, timeElapsed[0], timeElapsed[1]); }
private void TestOneCase(int[] aCoeff, int[] bCoeff, int[] expQuotient, int[] expRemainder) { GaloisField256 gfield = GaloisField256.QRCodeGaloisField; Polynomial apoly = new Polynomial(gfield, aCoeff); Polynomial bpoly = new Polynomial(gfield, bCoeff); PolyDivideStruct pds = apoly.Divide(bpoly); int[] quotient = pds.Quotient.Coefficients; int[] remainder = pds.Remainder.Coefficients; if (!PolynomialExtensions.isEqual(quotient, expQuotient)) { Assert.Fail("Quotient not equal. Result {0}, Expect {1}", aCoeff.Length, bCoeff.Length); } if (!PolynomialExtensions.isEqual(remainder, expRemainder)) { Assert.Fail("Remainder not equal. Result {0}, Expect {1}", remainder.Length, aCoeff.Length); } }