diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-17 01:53:55 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-17 01:53:55 +0300 |
| commit | 99760f77db74d42108865cc412a47137b0ed384c (patch) | |
| tree | 44e540178d6d267b741c13c07bb17ce516965640 /src/detect/manifest | |
| parent | b42c6e661e5b02952f8990d9a16dce984e41463a (diff) | |
fix: detect grok background work from pinned status
Diffstat (limited to 'src/detect/manifest')
| -rw-r--r-- | src/detect/manifest/tests.rs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/detect/manifest/tests.rs b/src/detect/manifest/tests.rs index 12eb1235..ec1873f7 100644 --- a/src/detect/manifest/tests.rs +++ b/src/detect/manifest/tests.rs @@ -543,6 +543,53 @@ fn bottom_non_empty_lines_uses_bottom_occurrence_for_repeated_text() { ); } +#[test] +fn top_non_empty_lines_uses_top_occurrence_for_repeated_text() { + let content = "\nmarker\nold\n\nmiddle\nmarker\nnew\n"; + + assert_eq!( + region( + DetectionInput { + screen: content, + osc_title: "", + osc_progress: "", + }, + "top_non_empty_lines(2)" + ), + "\nmarker\nold\n" + ); +} + +#[test] +fn top_non_empty_lines_requires_a_canonical_positive_bounded_count() { + let name = "top_non_empty_lines"; + assert!(validate_region_name(&format!("{name}(1)")).is_ok()); + assert!(validate_region_name(&format!("{name}({})", u16::MAX)).is_ok()); + for count in ["0", "01", "+1", "65536", "999999999999999999999999"] { + assert!( + validate_region_name(&format!("{name}({count})")).is_err(), + "{name} accepted invalid count {count}" + ); + } +} + +#[test] +fn top_non_empty_lines_requires_engine_three_when_declared() { + let manifest = r#" +id = "grok" +version = "1" +min_engine_version = 2 + +[[rules]] +id = "background" +state = "working" +region = " top_non_empty_lines(1) " +contains = ["active"] +"#; + + assert!(parse_manifest(manifest).is_err()); +} + // --------------------------------------------------------------------------- // OSC rule tests — exercise the new osc_title / osc_progress regions against // the bundled Claude and Codex manifests. |
