mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-27 21:02:35 +00:00
test input cases satisfied (wont' built)
This commit is contained in:
@@ -25,25 +25,28 @@ use super::{GenericGF, GenericGFPoly};
|
|||||||
* Tests {@link GenericGFPoly}.
|
* Tests {@link GenericGFPoly}.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const FIELD :GenericGF= super::QR_CODE_FIELD_256;
|
const FIELD: GenericGF = super::QR_CODE_FIELD_256;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn testPolynomialString() {
|
fn testPolynomialString() {
|
||||||
assert_eq!("0", FIELD.getZero().to_string());
|
assert_eq!("0", FIELD.getZero().to_string());
|
||||||
assert_eq!("-1", FIELD.buildMonomial(0, -1).to_string());
|
assert_eq!("-1", FIELD.buildMonomial(0, -1).to_string());
|
||||||
let p = GenericGFPoly::new(Box::new(FIELD), &vec![3, 0, -2, 1, 1]).unwrap();
|
let p = GenericGFPoly::new(Box::new(FIELD), &vec![3, 0, -2, 1, 1]).unwrap();
|
||||||
assert_eq!("a^25x^4 - ax^2 + x + 1", p.to_string());
|
assert_eq!("a^25x^4 - ax^2 + x + 1", p.to_string());
|
||||||
let p = GenericGFPoly::new(Box::new(FIELD), &vec![3]).unwrap();
|
let p = GenericGFPoly::new(Box::new(FIELD), &vec![3]).unwrap();
|
||||||
assert_eq!("a^25", p.to_string());
|
assert_eq!("a^25", p.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn testZero() {
|
fn testZero() {
|
||||||
assert_eq!(*FIELD.getZero(),*FIELD.buildMonomial(1, 0));
|
assert_eq!(*FIELD.getZero(), *FIELD.buildMonomial(1, 0));
|
||||||
assert_eq!(*FIELD.getZero(), *FIELD.buildMonomial(1, 2).multiply(0).unwrap());
|
assert_eq!(
|
||||||
}
|
*FIELD.getZero(),
|
||||||
|
*FIELD.buildMonomial(1, 2).multiply_with_scalar(0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn testEvaluate() {
|
fn testEvaluate() {
|
||||||
assert_eq!(3, FIELD.buildMonomial(0, 3).evaluateAt(0));
|
assert_eq!(3, FIELD.buildMonomial(0, 3).evaluateAt(0));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ impl GenericGF {
|
|||||||
/**
|
/**
|
||||||
* @return the monomial representing coefficient * x^degree
|
* @return the monomial representing coefficient * x^degree
|
||||||
*/
|
*/
|
||||||
pub fn buildMonomial(&self, degree: usize, coefficient: usize) -> Box<GenericGFPoly> {
|
pub fn buildMonomial(&self, degree: usize, coefficient: i32) -> Box<GenericGFPoly> {
|
||||||
if (coefficient == 0) {
|
if (coefficient == 0) {
|
||||||
return self.zero;
|
return self.zero;
|
||||||
}
|
}
|
||||||
@@ -258,7 +258,7 @@ impl fmt::Display for GenericGF {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct GenericGFPoly {
|
pub struct GenericGFPoly {
|
||||||
field: Box<GenericGF>,
|
field: Box<GenericGF>,
|
||||||
coefficients: Vec<usize>,
|
coefficients: Vec<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq for GenericGFPoly {
|
impl PartialEq for GenericGFPoly {
|
||||||
@@ -280,7 +280,7 @@ impl GenericGFPoly {
|
|||||||
*/
|
*/
|
||||||
pub fn new(
|
pub fn new(
|
||||||
field: Box<GenericGF>,
|
field: Box<GenericGF>,
|
||||||
coefficients: &Vec<usize>,
|
coefficients: &Vec<i32>,
|
||||||
) -> Result<Self, IllegalArgumentException> {
|
) -> Result<Self, IllegalArgumentException> {
|
||||||
if (coefficients.len() == 0) {
|
if (coefficients.len() == 0) {
|
||||||
return Err(IllegalArgumentException::new(""));
|
return Err(IllegalArgumentException::new(""));
|
||||||
@@ -472,7 +472,7 @@ impl GenericGFPoly {
|
|||||||
pub fn multiplyByMonomial(
|
pub fn multiplyByMonomial(
|
||||||
&self,
|
&self,
|
||||||
degree: usize,
|
degree: usize,
|
||||||
coefficient: usize,
|
coefficient: i32,
|
||||||
) -> Result<Box<GenericGFPoly>, IllegalArgumentException> {
|
) -> Result<Box<GenericGFPoly>, IllegalArgumentException> {
|
||||||
if (degree < 0) {
|
if (degree < 0) {
|
||||||
return Err(IllegalArgumentException::new(""));
|
return Err(IllegalArgumentException::new(""));
|
||||||
|
|||||||
Reference in New Issue
Block a user