use checkpointkit::{load, save, ProgressTracker};
use proptest::prelude::*;
use std::time::Duration;
use tempfile::tempdir;
proptest! {
#[test]
fn test_save_and_load_roundtrip_string(s in ".*") {
let dir = tempdir().unwrap();
let path = dir.path().join("prop.json");
save(&path, &s).unwrap();
let loaded: Option<String> = load(&path).unwrap();
prop_assert_eq!(loaded, Some(s));
}
#[test]
fn test_save_and_load_roundtrip_vec(v in prop::collection::vec(any::<i32>(), 0..100)) {
let dir = tempdir().unwrap();
let path = dir.path().join("prop.json");
save(&path, &v).unwrap();
let loaded: Option<Vec<i32>> = load(&path).unwrap();
prop_assert_eq!(loaded, Some(v));
}
#[test]
fn test_progress_tracker_monotonicity(increments in prop::collection::vec(0..100u64, 1..50)) {
let dir = tempdir().unwrap();
let path = dir.path().join("progress.json");
let total = increments.iter().sum::<u64>() + 100;
let mut tracker = ProgressTracker::new(total, &path, Duration::ZERO).unwrap();
let mut expected = 0;
for inc in increments {
expected += inc;
tracker.increment(inc).unwrap();
prop_assert_eq!(tracker.current(), expected);
prop_assert_eq!(tracker.resume().unwrap(), expected);
}
}
}
mod test_depth_property;