#[test]
fn test_format_size_large_gb_cov() {
let size = 100 * 1024 * 1024 * 1024; assert!(format_size(size).contains("GB"));
}
#[test]
fn test_benchmark_suites_tensor_ops_exists_cov() {
let found = BENCHMARK_SUITES
.iter()
.any(|(name, _)| *name == "tensor_ops");
assert!(found);
}
#[test]
fn test_benchmark_suites_inference_exists_cov() {
let found = BENCHMARK_SUITES
.iter()
.any(|(name, _)| *name == "inference");
assert!(found);
}
#[test]
fn test_benchmark_suites_cache_exists_cov() {
let found = BENCHMARK_SUITES.iter().any(|(name, _)| *name == "cache");
assert!(found);
}
#[test]
fn test_benchmark_suites_lambda_exists_cov() {
let found = BENCHMARK_SUITES.iter().any(|(name, _)| *name == "lambda");
assert!(found);
}
#[test]
fn test_benchmark_suites_comparative_exists_cov() {
let found = BENCHMARK_SUITES
.iter()
.any(|(name, _)| *name == "comparative");
assert!(found);
}
#[test]
fn test_display_model_info_unknown_format_cov() {
let result = display_model_info("unknown.bin", &[1, 2, 3, 4, 5]);
assert!(result.is_ok());
}
#[test]
fn test_display_model_info_empty_data_cov() {
let result = display_model_info("empty.bin", &[]);
assert!(result.is_ok());
}
#[test]
fn test_display_model_info_apr_extension_cov() {
let result = display_model_info("model.apr", &[0; 10]);
assert!(result.is_ok());
}
#[test]
fn test_run_benchmarks_with_all_options_cov() {
let result = run_benchmarks(
Some("tensor_ops".to_string()),
true, Some("realizar".to_string()),
Some("model.gguf".to_string()),
Some("http://localhost:8080".to_string()),
Some("output.json".to_string()),
);
assert!(result.is_ok());
}
#[test]
fn test_is_local_file_path_empty_cov() {
assert!(!is_local_file_path(""));
}
#[test]
fn test_is_local_file_path_url_without_extension_cov() {
assert!(!is_local_file_path("http://example.com/model"));
assert!(!is_local_file_path("pacha://registry/model"));
assert!(is_local_file_path("https://example.com/model.gguf"));
}
#[test]
fn test_is_local_file_path_parent_dir_cov() {
assert!(is_local_file_path("../model.gguf"));
assert!(is_local_file_path("../../models/file.safetensors"));
}
#[test]
fn test_is_local_file_path_windows_style_cov() {
assert!(is_local_file_path("C:\\models\\model.gguf"));
}
#[test]
fn test_validate_suite_name_case_sensitive_cov() {
assert!(!validate_suite_name("TENSOR_OPS"));
assert!(!validate_suite_name("Inference"));
assert!(validate_suite_name("tensor_ops"));
}
#[test]
fn test_validate_suite_name_partial_match_cov() {
assert!(!validate_suite_name("tensor"));
assert!(!validate_suite_name("ops"));
assert!(!validate_suite_name("infer"));
}
#[test]
fn test_format_size_zero_cov() {
assert_eq!(format_size(0), "0 B");
}
#[test]
fn test_format_size_exact_kb_cov() {
assert_eq!(format_size(1024), "1.0 KB");
}
#[test]
fn test_format_size_exact_mb_cov() {
assert_eq!(format_size(1024 * 1024), "1.0 MB");
}
#[test]
fn test_format_size_exact_gb_cov() {
assert_eq!(format_size(1024 * 1024 * 1024), "1.0 GB");
}
#[test]
fn test_format_size_large_tb_cov() {
let ten_tb = 10u64 * 1024 * 1024 * 1024 * 1024;
let result = format_size(ten_tb);
assert!(result.contains("GB"));
}
#[test]
fn test_format_size_fractional_mb_cov() {
let bytes = 1500 * 1024u64; let result = format_size(bytes);
assert!(result.contains("MB"));
}
#[test]
fn test_print_info_cov() {
print_info();
}
#[test]
fn test_home_dir_returns_path_cov() {
let _ = home_dir();
}
#[test]
fn test_validate_suite_name_all_valid_cov() {
assert!(validate_suite_name("tensor_ops"));
assert!(validate_suite_name("inference"));
assert!(validate_suite_name("cache"));
assert!(validate_suite_name("tokenizer"));
assert!(validate_suite_name("quantize"));
assert!(validate_suite_name("lambda"));
assert!(validate_suite_name("comparative"));
}
#[test]
fn test_validate_suite_name_empty_cov() {
assert!(!validate_suite_name(""));
}
#[test]
fn test_validate_suite_name_whitespace_cov() {
assert!(!validate_suite_name(" "));
assert!(!validate_suite_name("\t"));
assert!(!validate_suite_name(" tensor_ops "));
}
#[test]
fn test_parse_cargo_bench_output_empty_input_cov() {
let results = parse_cargo_bench_output("", None);
assert!(results.is_empty());
}
#[test]
fn test_parse_cargo_bench_output_no_bench_lines_ext_cov() {
let output = "This is some random output\nwithout any benchmark data";
let results = parse_cargo_bench_output(output, None);
assert!(results.is_empty());
}
#[test]
fn test_parse_cargo_bench_output_multiple_benches_cov() {
let output = "test bench_one ... bench: 100 ns/iter (+/- 10)\ntest bench_two ... bench: 200 ns/iter (+/- 20)";
let results = parse_cargo_bench_output(output, Some("multi"));
assert_eq!(results.len(), 2);
}
#[test]
fn test_parse_cargo_bench_output_with_commas_cov() {
let output = "test big_bench ... bench: 1,000,000 ns/iter (+/- 100)";
let results = parse_cargo_bench_output(output, None);
assert_eq!(results.len(), 1);
assert_eq!(results[0]["time_ns"], 1000000);
}
#[test]
fn test_benchmark_suites_descriptions_not_empty_cov() {
for (name, description) in BENCHMARK_SUITES {
assert!(!name.is_empty());
assert!(!description.is_empty());
}
}
#[test]
fn test_benchmark_suites_unique_names_cov() {
let names: Vec<&str> = BENCHMARK_SUITES.iter().map(|(n, _)| *n).collect();
let unique_count = names.iter().collect::<std::collections::HashSet<_>>().len();
assert_eq!(names.len(), unique_count);
}
#[test]
fn test_is_local_file_path_dot_slash_cov() {
assert!(is_local_file_path("./model.gguf"));
assert!(is_local_file_path("./subdir/model.safetensors"));
}
#[test]
fn test_is_local_file_path_only_extension_cov() {
assert!(is_local_file_path("model.gguf"));
assert!(is_local_file_path("model.safetensors"));
assert!(is_local_file_path("model.apr"));
}
#[test]
fn test_is_local_file_path_no_extension_cov() {
assert!(!is_local_file_path("model"));
assert!(!is_local_file_path("model.txt"));
assert!(!is_local_file_path("model.bin"));
}
#[test]
fn test_run_visualization_small_samples_cov() {
run_visualization(false, 5);
}
#[test]
fn test_run_visualization_large_samples_cov() {
run_visualization(true, 100);
}
#[test]
fn test_display_model_info_safetensors_ext_cov() {
let result = display_model_info("model.safetensors", &[0; 8]);
assert!(result.is_err() || result.is_ok());
}
#[test]
fn test_display_model_info_gguf_ext_cov() {
let result = display_model_info("model.gguf", &[0; 8]);
assert!(result.is_err() || result.is_ok());
}
#[test]
fn test_format_size_exact_boundaries_cov() {
assert_eq!(format_size(1024), "1.0 KB");
assert_eq!(format_size(1024 * 1024), "1.0 MB");
assert_eq!(format_size(1024 * 1024 * 1024), "1.0 GB");
}
#[test]
fn test_format_size_just_below_boundaries_cov() {
assert_eq!(format_size(1023), "1023 B");
assert_eq!(format_size(1024 * 1024 - 1), "1024.0 KB");
assert_eq!(format_size(1024 * 1024 * 1024 - 1), "1024.0 MB");
}
#[test]
fn test_format_size_large_values_cov() {
assert_eq!(format_size(10 * 1024 * 1024 * 1024), "10.0 GB");
assert_eq!(format_size(100 * 1024 * 1024 * 1024), "100.0 GB");
}
#[test]
fn test_parse_cargo_bench_output_nonnumeric_ext_cov() {
let output = "test name bench: abc ns/iter (+/- 10)"; let results = parse_cargo_bench_output(output, None);
assert!(results.is_empty()); }
#[test]
fn test_parse_cargo_bench_output_no_test_keyword_ext_cov() {
let output = "bench_name ... bench: 100 ns/iter (+/- 10)"; let results = parse_cargo_bench_output(output, None);
assert!(results.is_empty());
}
#[test]
fn test_parse_cargo_bench_output_too_few_parts_ext_cov() {
let output = "test bench"; let results = parse_cargo_bench_output(output, None);
assert!(results.is_empty());
}
#[test]
fn test_parse_cargo_bench_output_with_suite_name_ext_cov() {
let output = "test bench_test ... bench: 500 ns/iter (+/- 50)";
let results = parse_cargo_bench_output(output, Some("my_suite"));
assert_eq!(results.len(), 1);
assert_eq!(results[0]["suite"], "my_suite");
}
#[test]
fn test_parse_cargo_bench_output_large_comma_separated_ext_cov() {
let output = "test slow_bench ... bench: 50,000 ns/iter (+/- 1000)";
let results = parse_cargo_bench_output(output, None);
assert_eq!(results.len(), 1);
assert_eq!(results[0]["time_ns"], 50000);
}
#[test]
fn test_is_local_file_path_relative_subdirs_ext_cov() {
assert!(is_local_file_path("./models/model.gguf"));
assert!(is_local_file_path("../model.safetensors"));
assert!(is_local_file_path("models/subdir/file.apr"));
}
#[test]
fn test_is_local_file_path_absolute_linux_ext_cov() {
assert!(is_local_file_path("/home/user/models/model.gguf"));
assert!(is_local_file_path("/var/models/model.safetensors"));
}
#[test]
fn test_is_local_file_path_url_with_ext_ext_cov() {
assert!(is_local_file_path("http://example.com/model.gguf"));
assert!(is_local_file_path("https://example.com/model.safetensors"));
assert!(!is_local_file_path("http://example.com/model"));
assert!(!is_local_file_path("s3://bucket/model.bin"));
}
#[test]
fn test_validate_suite_name_iterate_all_ext_cov() {
for (name, _) in BENCHMARK_SUITES {
assert!(validate_suite_name(name), "Suite {name} should be valid");
}
}