use morphology_img::RenderConfig; use std::path::PathBuf; #[test] fn test_default_config() { let config = RenderConfig::default(); assert_eq!(config.output_dir, PathBuf::from("output")); assert!(!config.keep_temp_files); assert_eq!(config.lilypond_binary, PathBuf::from("lilypond")); } #[test] fn test_new_config() { let config = RenderConfig::new("my-output"); assert_eq!(config.output_dir, PathBuf::from("my-output")); assert!(!config.keep_temp_files); assert_eq!(config.lilypond_binary, PathBuf::from("lilypond")); } #[test] fn test_new_config_with_pathbuf() { let path = PathBuf::from("/absolute/path/to/output"); let config = RenderConfig::new(path.clone()); assert_eq!(config.output_dir, path); } #[test] fn test_builder_keep_temp_files() { let config = RenderConfig::new("output") .keep_temp_files(true); assert!(config.keep_temp_files); assert_eq!(config.output_dir, PathBuf::from("output")); } #[test] fn test_builder_keep_temp_files_false() { let config = RenderConfig::new("output") .keep_temp_files(false); assert!(!config.keep_temp_files); } #[test] fn test_builder_lilypond_binary_str() { let config = RenderConfig::new("output") .lilypond_binary("/usr/local/bin/lilypond"); assert_eq!(config.lilypond_binary, PathBuf::from("/usr/local/bin/lilypond")); assert_eq!(config.output_dir, PathBuf::from("output")); } #[test] fn test_builder_lilypond_binary_pathbuf() { let lilypond_path = PathBuf::from("/custom/path/lilypond"); let config = RenderConfig::new("output") .lilypond_binary(lilypond_path.clone()); assert_eq!(config.lilypond_binary, lilypond_path); } #[test] fn test_builder_method_chaining() { let config = RenderConfig::new("my-output") .keep_temp_files(true) .lilypond_binary("/usr/bin/lilypond"); assert_eq!(config.output_dir, PathBuf::from("my-output")); assert!(config.keep_temp_files); assert_eq!(config.lilypond_binary, PathBuf::from("/usr/bin/lilypond")); } #[test] fn test_builder_order_independence() { // Test that builder methods work in any order let config1 = RenderConfig::new("output") .keep_temp_files(true) .lilypond_binary("/usr/bin/lilypond"); let config2 = RenderConfig::new("output") .lilypond_binary("/usr/bin/lilypond") .keep_temp_files(true); assert_eq!(config1.output_dir, config2.output_dir); assert_eq!(config1.keep_temp_files, config2.keep_temp_files); assert_eq!(config1.lilypond_binary, config2.lilypond_binary); } #[test] fn test_config_is_clonable() { let config1 = RenderConfig::new("output") .keep_temp_files(true) .lilypond_binary("/usr/bin/lilypond"); let config2 = config1.clone(); assert_eq!(config1.output_dir, config2.output_dir); assert_eq!(config1.keep_temp_files, config2.keep_temp_files); assert_eq!(config1.lilypond_binary, config2.lilypond_binary); } #[test] fn test_config_is_debuggable() { let config = RenderConfig::new("output"); let debug_str = format!("{:?}", config); // Should contain the struct name and fields assert!(debug_str.contains("RenderConfig")); } #[test] fn test_multiple_configs_independent() { let config1 = RenderConfig::new("output1") .keep_temp_files(true); let config2 = RenderConfig::new("output2") .keep_temp_files(false); // Verify they're independent assert_eq!(config1.output_dir, PathBuf::from("output1")); assert_eq!(config2.output_dir, PathBuf::from("output2")); assert!(config1.keep_temp_files); assert!(!config2.keep_temp_files); } #[test] fn test_config_with_relative_path() { let config = RenderConfig::new("./relative/path"); assert_eq!(config.output_dir, PathBuf::from("./relative/path")); } #[test] fn test_config_with_absolute_path() { let config = RenderConfig::new("/absolute/path"); assert_eq!(config.output_dir, PathBuf::from("/absolute/path")); } #[test] fn test_builder_overwrites_previous_values() { let config = RenderConfig::new("output") .keep_temp_files(true) .keep_temp_files(false); // Override previous value assert!(!config.keep_temp_files); } #[test] fn test_config_fields_are_public() { let config = RenderConfig::new("output"); // Should be able to access fields directly let _output_dir = &config.output_dir; let _keep_temp = config.keep_temp_files; let _binary = &config.lilypond_binary; } #[test] fn test_default_values_are_sensible() { let config = RenderConfig::default(); // Default output directory should be "output" assert_eq!(config.output_dir, PathBuf::from("output")); // Should not keep temp files by default (for cleanliness) assert!(!config.keep_temp_files); // Should use system lilypond by default assert_eq!(config.lilypond_binary, PathBuf::from("lilypond")); } #[test] fn test_new_is_equivalent_to_default_with_custom_output() { let config_new = RenderConfig::new("custom-output"); let mut config_default = RenderConfig::default(); config_default.output_dir = PathBuf::from("custom-output"); assert_eq!(config_new.output_dir, config_default.output_dir); assert_eq!(config_new.keep_temp_files, config_default.keep_temp_files); assert_eq!(config_new.lilypond_binary, config_default.lilypond_binary); } #[test] fn test_default_max_batch_size_is_none() { let config = RenderConfig::default(); assert_eq!(config.max_batch_size, None); } #[test] fn test_builder_max_batch_size() { let config = RenderConfig::new("output") .max_batch_size(50); assert_eq!(config.max_batch_size, Some(50)); assert_eq!(config.output_dir, PathBuf::from("output")); } #[test] fn test_builder_max_batch_size_various_values() { let config1 = RenderConfig::new("output").max_batch_size(1); let config10 = RenderConfig::new("output").max_batch_size(10); let config100 = RenderConfig::new("output").max_batch_size(100); assert_eq!(config1.max_batch_size, Some(1)); assert_eq!(config10.max_batch_size, Some(10)); assert_eq!(config100.max_batch_size, Some(100)); } #[test] fn test_builder_with_all_options_including_max_batch_size() { let config = RenderConfig::new("my-output") .keep_temp_files(true) .lilypond_binary("/usr/bin/lilypond") .max_batch_size(25); assert_eq!(config.output_dir, PathBuf::from("my-output")); assert!(config.keep_temp_files); assert_eq!(config.lilypond_binary, PathBuf::from("/usr/bin/lilypond")); assert_eq!(config.max_batch_size, Some(25)); } #[test] fn test_builder_max_batch_size_overwrites() { let config = RenderConfig::new("output") .max_batch_size(10) .max_batch_size(20); // Override previous value assert_eq!(config.max_batch_size, Some(20)); } #[test] fn test_max_batch_size_field_is_public() { let config = RenderConfig::new("output").max_batch_size(15); // Should be able to access field directly let _batch_size = config.max_batch_size; assert_eq!(_batch_size, Some(15)); } #[test] fn test_default_parallel_is_false() { let config = RenderConfig::default(); assert!(!config.parallel); } #[test] fn test_builder_parallel_true() { let config = RenderConfig::new("output") .parallel(true); assert!(config.parallel); assert_eq!(config.output_dir, PathBuf::from("output")); } #[test] fn test_builder_parallel_false() { let config = RenderConfig::new("output") .parallel(false); assert!(!config.parallel); } #[test] fn test_builder_parallel_overwrites() { let config = RenderConfig::new("output") .parallel(true) .parallel(false); // Override previous value assert!(!config.parallel); } #[test] fn test_builder_with_all_options_including_parallel() { let config = RenderConfig::new("my-output") .keep_temp_files(true) .lilypond_binary("/usr/bin/lilypond") .max_batch_size(25) .parallel(true); assert_eq!(config.output_dir, PathBuf::from("my-output")); assert!(config.keep_temp_files); assert_eq!(config.lilypond_binary, PathBuf::from("/usr/bin/lilypond")); assert_eq!(config.max_batch_size, Some(25)); assert!(config.parallel); } #[test] fn test_parallel_field_is_public() { let config = RenderConfig::new("output").parallel(true); // Should be able to access field directly let _parallel = config.parallel; assert!(_parallel); }