test input cases satisfied (wont' built)

This commit is contained in:
Henry Schimke
2022-08-23 13:44:14 -05:00
parent 63410c4615
commit a47796c3b8
2 changed files with 21 additions and 18 deletions

View File

@@ -40,7 +40,10 @@ use super::{GenericGF, GenericGFPoly};
#[test]
fn testZero() {
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]

View File

@@ -157,7 +157,7 @@ impl GenericGF {
/**
* @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) {
return self.zero;
}
@@ -258,7 +258,7 @@ impl fmt::Display for GenericGF {
#[derive(Debug)]
pub struct GenericGFPoly {
field: Box<GenericGF>,
coefficients: Vec<usize>,
coefficients: Vec<i32>,
}
impl PartialEq for GenericGFPoly {
@@ -280,7 +280,7 @@ impl GenericGFPoly {
*/
pub fn new(
field: Box<GenericGF>,
coefficients: &Vec<usize>,
coefficients: &Vec<i32>,
) -> Result<Self, IllegalArgumentException> {
if (coefficients.len() == 0) {
return Err(IllegalArgumentException::new(""));
@@ -472,7 +472,7 @@ impl GenericGFPoly {
pub fn multiplyByMonomial(
&self,
degree: usize,
coefficient: usize,
coefficient: i32,
) -> Result<Box<GenericGFPoly>, IllegalArgumentException> {
if (degree < 0) {
return Err(IllegalArgumentException::new(""));