#[macro_use] extern crate doc_comment; doctest!("../README.md"); use {golomb_set::UnpackedGcs, proptest::prelude::*, twox_hash::XxHash}; proptest! { #[test] fn add_query_unpacked_single(bytes: Vec) { let gcs = { let mut unpacked = UnpackedGcs::::new(10, 9); unpacked.insert(&bytes).unwrap(); unpacked }; assert!(gcs.contains(&bytes)); } #[test] fn add_query_packed_single(bytes: Vec) { let gcs = { let mut unpacked = UnpackedGcs::::new(10, 9); unpacked.insert(&bytes).unwrap(); unpacked.pack() }; assert!(gcs.contains(&bytes)); } #[test] fn invalid_query_unpacked_single(a: Vec, b: Vec, n in 0i32..100000i32, p in 2u8..16) { if a == b { return Ok(()); } let gcs = { let mut unpacked = UnpackedGcs::::new(n as usize, p); unpacked.insert(&a).unwrap(); unpacked }; assert!(!gcs.contains(&b)); } #[test] fn invalid_query_packed_single(a: Vec, b: Vec, n in 0i32..10000i32, p in 2u8..16) { if a == b { return Ok(()); } let gcs = { let mut unpacked = UnpackedGcs::::new(n as usize, p); unpacked.insert(&a).unwrap(); unpacked.pack() }; assert!(!gcs.contains(&b)); } // Tests the packing/unpacking roundtrip #[test] fn pack_roundtrip(n in 0usize..10000usize, p in 2u8..16, data: Vec>) { if n < data.len() { return Ok(()); } let mut gcs = UnpackedGcs::::new(n, p); for elem in data { gcs.insert(elem).unwrap(); } assert_eq!(gcs, gcs.pack().unpack()); } }