#[derive(Debug, Clone)]
pub struct ExportOptions {
pub include_system_allocations: bool,
pub verbose_logging: bool,
pub buffer_size: usize,
}
impl Default for ExportOptions {
fn default() -> Self {
Self {
include_system_allocations: false,
verbose_logging: false,
buffer_size: 64 * 1024,
}
}
}
impl ExportOptions {
pub fn new() -> Self {
Self::default()
}
pub fn include_system_allocations(mut self, include: bool) -> Self {
self.include_system_allocations = include;
self
}
pub fn verbose_logging(mut self, verbose: bool) -> Self {
self.verbose_logging = verbose;
self
}
pub fn buffer_size(mut self, size: usize) -> Self {
self.buffer_size = size;
self
}
}
#[derive(Debug, Clone, Copy)]
pub enum ExportMode {
UserFocused,
Complete,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_export_options_default() {
let options = ExportOptions::default();
assert!(
!options.include_system_allocations,
"Default include_system_allocations should be false"
);
assert!(
!options.verbose_logging,
"Default verbose_logging should be false"
);
assert_eq!(
options.buffer_size,
64 * 1024,
"Default buffer_size should be 64KB"
);
}
#[test]
fn test_export_options_new() {
let options = ExportOptions::new();
let default_options = ExportOptions::default();
assert_eq!(
options.include_system_allocations, default_options.include_system_allocations,
"new() should match default()"
);
assert_eq!(
options.verbose_logging, default_options.verbose_logging,
"new() should match default()"
);
assert_eq!(
options.buffer_size, default_options.buffer_size,
"new() should match default()"
);
}
#[test]
fn test_export_options_include_system_allocations() {
let options = ExportOptions::new().include_system_allocations(true);
assert!(
options.include_system_allocations,
"include_system_allocations should be true"
);
}
#[test]
fn test_export_options_exclude_system_allocations() {
let options = ExportOptions::new().include_system_allocations(false);
assert!(
!options.include_system_allocations,
"include_system_allocations should be false"
);
}
#[test]
fn test_export_options_verbose_logging() {
let options = ExportOptions::new().verbose_logging(true);
assert!(options.verbose_logging, "verbose_logging should be true");
}
#[test]
fn test_export_options_buffer_size() {
let options = ExportOptions::new().buffer_size(128 * 1024);
assert_eq!(
options.buffer_size,
128 * 1024,
"buffer_size should be 128KB"
);
}
#[test]
fn test_export_options_chained_builders() {
let options = ExportOptions::new()
.include_system_allocations(true)
.verbose_logging(true)
.buffer_size(256 * 1024);
assert!(
options.include_system_allocations,
"include_system_allocations should be true"
);
assert!(options.verbose_logging, "verbose_logging should be true");
assert_eq!(
options.buffer_size,
256 * 1024,
"buffer_size should be 256KB"
);
}
#[test]
fn test_export_options_clone() {
let original = ExportOptions::new()
.include_system_allocations(true)
.verbose_logging(true)
.buffer_size(128 * 1024);
let cloned = original.clone();
assert_eq!(
original.include_system_allocations, cloned.include_system_allocations,
"Cloned include_system_allocations should match"
);
assert_eq!(
original.verbose_logging, cloned.verbose_logging,
"Cloned verbose_logging should match"
);
assert_eq!(
original.buffer_size, cloned.buffer_size,
"Cloned buffer_size should match"
);
}
#[test]
fn test_export_options_debug() {
let options = ExportOptions::new();
let debug_str = format!("{:?}", options);
assert!(
debug_str.contains("ExportOptions"),
"Debug should contain struct name"
);
assert!(
debug_str.contains("include_system_allocations"),
"Debug should contain field name"
);
assert!(
debug_str.contains("verbose_logging"),
"Debug should contain field name"
);
assert!(
debug_str.contains("buffer_size"),
"Debug should contain field name"
);
}
#[test]
fn test_export_mode_variants() {
let user_focused = ExportMode::UserFocused;
let complete = ExportMode::Complete;
let debug_focused = format!("{:?}", user_focused);
let debug_complete = format!("{:?}", complete);
assert!(
debug_focused.contains("UserFocused"),
"Debug should contain UserFocused"
);
assert!(
debug_complete.contains("Complete"),
"Debug should contain Complete"
);
}
#[test]
fn test_export_mode_clone() {
let original = ExportMode::Complete;
let cloned = original;
assert!(
matches!(cloned, ExportMode::Complete),
"Cloned mode should be Complete"
);
}
#[test]
fn test_export_mode_copy() {
let original = ExportMode::UserFocused;
let copied = original;
assert!(
matches!(original, ExportMode::UserFocused),
"Original should still be valid after copy"
);
assert!(
matches!(copied, ExportMode::UserFocused),
"Copied should be UserFocused"
);
}
#[test]
fn test_export_options_zero_buffer_size() {
let options = ExportOptions::new().buffer_size(0);
assert_eq!(options.buffer_size, 0, "buffer_size should be 0");
}
#[test]
fn test_export_options_large_buffer_size() {
let large_size = 1024 * 1024 * 1024;
let options = ExportOptions::new().buffer_size(large_size);
assert_eq!(options.buffer_size, large_size, "buffer_size should be 1GB");
}
#[test]
fn test_export_options_builder_override() {
let options = ExportOptions::new().buffer_size(1024).buffer_size(2048);
assert_eq!(
options.buffer_size, 2048,
"Later buffer_size should override earlier"
);
}
}