1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// ========================================================================
// InferenceOutput: structural tests
// ========================================================================
/// InferenceOutput fields should be independently accessible.
/// Bug class: private field preventing test access (compile-time check).
#[test]
fn inference_output_fields() {
let output = InferenceOutput {
text: "hello".to_string(),
tokens_generated: Some(5),
inference_ms: Some(10.0),
tok_per_sec: Some(500.0),
used_gpu: Some(false),
generated_tokens: Some(vec![1, 2, 3, 4, 5]),
};
assert_eq!(output.text, "hello");
assert_eq!(output.tokens_generated, Some(5));
assert!((output.inference_ms.expect("inference_ms") - 10.0).abs() < f64::EPSILON);
}
/// InferenceOutput with no metrics.
#[test]
fn inference_output_no_metrics() {
let output = InferenceOutput {
text: "result".to_string(),
tokens_generated: None,
inference_ms: None,
tok_per_sec: None,
used_gpu: None,
generated_tokens: None,
};
assert!(output.tokens_generated.is_none());
assert!(output.inference_ms.is_none());
}
// ========================================================================
// find_model_in_dir / glob_first: edge cases
// ========================================================================
/// find_model_in_dir on a regular file path (not directory) returns the path.
/// Bug class: panic when path is not a directory.
#[test]
fn find_model_in_dir_file_path_returns_self() {
let result = find_model_in_dir(Path::new("/nonexistent/file.txt"));
assert_eq!(
result.expect("should not error"),
PathBuf::from("/nonexistent/file.txt")
);
}
/// glob_first on empty pattern returns None.
/// Bug class: panic on empty or invalid glob.
#[test]
fn glob_first_empty_pattern() {
let result = glob_first(Path::new(""));
// Empty path may or may not match; key property: no panic
let _ = result;
}