示例#1
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);
            }
        }
示例#2
0
        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);
            }
        }