Skip to content

Commit

Permalink
proptest
Browse files Browse the repository at this point in the history
  • Loading branch information
supinie committed Feb 6, 2024
1 parent 2c957f6 commit 2d79247
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/tests/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pub(in crate::tests) mod buffer_tests {
use crate::{params::*, polynomials::*, vectors::*};
use rand::Rng;
use proptest::prelude::*;
extern crate std;
use std::vec;
use std::vec::Vec;
Expand All @@ -27,18 +28,33 @@ pub(in crate::tests) mod buffer_tests {
data
}

#[test]
fn pack_unpack_poly_test() {
let poly = Poly { coeffs: [20; N] };
let mut buffer = [0; POLYBYTES];
poly.pack(&mut buffer);
proptest! {
#[test]
fn pack_unpack_poly_test(a in prop::array::uniform(-(Q as i16)..(Q as i16))) {
let mut poly = Poly::from(a);
poly.normalise();
let mut buffer = [0; POLYBYTES];
poly.pack(&mut buffer);

let mut comp_poly = Poly::new();
comp_poly.unpack(&buffer);
let mut comp_poly = Poly::new();
comp_poly.unpack(&buffer);

assert_eq!(comp_poly.coeffs, poly.coeffs);
assert_eq!(poly, comp_poly);
}
}

// #[test]
// fn pack_unpack_poly_test() {
// let poly = Poly { coeffs: [20; N] };
// let mut buffer = [0; POLYBYTES];
// poly.pack(&mut buffer);

// let mut comp_poly = Poly::new();
// comp_poly.unpack(&buffer);

// assert_eq!(comp_poly.coeffs, poly.coeffs);
// }

#[test]
fn compress_decompress_poly_test() {
for sec_level in &TEST_PARAMS {
Expand Down

0 comments on commit 2d79247

Please sign in to comment.