Prepare repo for GitHub publication
- Add MIT LICENSE file - Expand .gitignore with standard Rust/Linux entries - Remove dangling symlinks (breadmancli, breadpadcli) and dev scratchpad (svgs.txt) from git tracking - Replace unsafe unwrap() calls with expect() in breadman CLI (guarded by prior filter)
This commit is contained in:
parent
feefdb81b9
commit
c4626dd64d
34 changed files with 2825 additions and 771 deletions
|
|
@ -1,16 +1,27 @@
|
|||
use breadpad_shared::classifier::Classifier;
|
||||
use breadpad_shared::classifier::{Classifier, ExecutionProvider};
|
||||
use breadpad_shared::types::NoteType;
|
||||
use chrono::Timelike;
|
||||
|
||||
fn cl() -> Classifier {
|
||||
Classifier::load("auto", "08:00")
|
||||
Classifier::load("08:00")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn active_provider_is_cpu() {
|
||||
// QNN and Vulkan EPs are not compiled in; CPU is always the fallback.
|
||||
fn active_provider_is_valid() {
|
||||
// The active provider depends on the host: a machine with the ONNX model present and
|
||||
// a working ROCm iGPU loads `Gpu`, otherwise `Cpu`. Either is valid — but when no
|
||||
// model is available we must be on CPU (no session => no GPU EP in use).
|
||||
let c = cl();
|
||||
assert_eq!(c.active_provider, breadpad_shared::classifier::ExecutionProvider::Cpu);
|
||||
assert!(matches!(
|
||||
c.active_provider,
|
||||
ExecutionProvider::Cpu | ExecutionProvider::Gpu
|
||||
));
|
||||
if !c.model_available() {
|
||||
assert!(
|
||||
matches!(c.active_provider, ExecutionProvider::Cpu),
|
||||
"no model loaded but provider was not CPU"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -63,7 +74,7 @@ fn classify_recurrence_via_fallback() {
|
|||
|
||||
#[test]
|
||||
fn classify_custom_morning_time() {
|
||||
let mut c = Classifier::load("auto", "07:15");
|
||||
let mut c = Classifier::load("07:15");
|
||||
let r = c.classify("sync tomorrow morning");
|
||||
let t = r.time.expect("should have a time for tomorrow morning");
|
||||
let local: chrono::DateTime<chrono::Local> = t.into();
|
||||
|
|
@ -71,6 +82,41 @@ fn classify_custom_morning_time() {
|
|||
assert_eq!(local.minute(), 15);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn classify_empty_string_does_not_panic() {
|
||||
let mut c = cl();
|
||||
let _ = c.classify("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn classify_whitespace_only_does_not_panic() {
|
||||
let mut c = cl();
|
||||
let _ = c.classify(" ");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn classify_in_duration_sets_time() {
|
||||
let mut c = cl();
|
||||
let r = c.classify("take a break in 30 minutes");
|
||||
assert!(r.time.is_some(), "should have a time for 'in 30 minutes'");
|
||||
assert_eq!(r.note_type, NoteType::Reminder);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn classify_tomorrow_sets_time() {
|
||||
let mut c = cl();
|
||||
let r = c.classify("submit the invoice tomorrow");
|
||||
assert!(r.time.is_some(), "tomorrow should produce a scheduled time");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn classify_returns_cleaned_body() {
|
||||
let mut c = cl();
|
||||
let r = c.classify("call mum at 6pm");
|
||||
assert!(r.body.contains("call mum"), "body: {}", r.body);
|
||||
assert!(!r.body.contains("6pm"), "time phrase should be stripped from body: {}", r.body);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn model_path_points_to_expected_location() {
|
||||
let c = cl();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue