chore: enforce argument-comment lint across all targets

This commit is contained in:
Michael Bolin
2026-03-27 16:14:21 -07:00
parent 5b71e5104f
commit a4fa041e7f
359 changed files with 10414 additions and 6807 deletions

View File

@@ -5,37 +5,83 @@ use pretty_assertions::assert_eq;
#[test]
fn split_string_works() {
assert_eq!(split_string("hello world", 5, 5), (1, "hello", "world"));
assert_eq!(split_string("abc", 0, 0), (3, "", ""));
assert_eq!(
split_string(
"hello world",
/*beginning_bytes*/ 5,
/*end_bytes*/ 5
),
(1, "hello", "world")
);
assert_eq!(
split_string("abc", /*beginning_bytes*/ 0, /*end_bytes*/ 0),
(3, "", "")
);
}
#[test]
fn split_string_handles_empty_string() {
assert_eq!(split_string("", 4, 4), (0, "", ""));
assert_eq!(
split_string("", /*beginning_bytes*/ 4, /*end_bytes*/ 4),
(0, "", "")
);
}
#[test]
fn split_string_only_keeps_prefix_when_tail_budget_is_zero() {
assert_eq!(split_string("abcdef", 3, 0), (3, "abc", ""));
assert_eq!(
split_string("abcdef", /*beginning_bytes*/ 3, /*end_bytes*/ 0),
(3, "abc", "")
);
}
#[test]
fn split_string_only_keeps_suffix_when_prefix_budget_is_zero() {
assert_eq!(split_string("abcdef", 0, 3), (3, "", "def"));
assert_eq!(
split_string("abcdef", /*beginning_bytes*/ 0, /*end_bytes*/ 3),
(3, "", "def")
);
}
#[test]
fn split_string_handles_overlapping_budgets_without_removal() {
assert_eq!(split_string("abcdef", 4, 4), (0, "abcd", "ef"));
assert_eq!(
split_string("abcdef", /*beginning_bytes*/ 4, /*end_bytes*/ 4),
(0, "abcd", "ef")
);
}
#[test]
fn split_string_respects_utf8_boundaries() {
assert_eq!(split_string("😀abc😀", 5, 5), (1, "😀a", "c😀"));
assert_eq!(
split_string("😀abc😀", /*beginning_bytes*/ 5, /*end_bytes*/ 5),
(1, "😀a", "c😀")
);
assert_eq!(split_string("😀😀😀😀😀", 1, 1), (5, "", ""));
assert_eq!(split_string("😀😀😀😀😀", 7, 7), (3, "😀", "😀"));
assert_eq!(split_string("😀😀😀😀😀", 8, 8), (1, "😀😀", "😀😀"));
assert_eq!(
split_string(
"😀😀😀😀😀",
/*beginning_bytes*/ 1,
/*end_bytes*/ 1
),
(5, "", "")
);
assert_eq!(
split_string(
"😀😀😀😀😀",
/*beginning_bytes*/ 7,
/*end_bytes*/ 7
),
(3, "😀", "😀")
);
assert_eq!(
split_string(
"😀😀😀😀😀",
/*beginning_bytes*/ 8,
/*end_bytes*/ 8
),
(1, "😀😀", "😀😀")
);
}
#[test]
@@ -50,7 +96,7 @@ fn truncate_with_token_budget_returns_original_when_under_limit() {
#[test]
fn truncate_with_token_budget_reports_truncation_at_zero_limit() {
let s = "abcdef";
let (out, original) = truncate_middle_with_token_budget(s, 0);
let (out, original) = truncate_middle_with_token_budget(s, /*max_tokens*/ 0);
assert_eq!(out, "…2 tokens truncated…");
assert_eq!(original, Some(2));
}
@@ -58,7 +104,7 @@ fn truncate_with_token_budget_reports_truncation_at_zero_limit() {
#[test]
fn truncate_middle_tokens_handles_utf8_content() {
let s = "😀😀😀😀😀😀😀😀😀😀\nsecond line with text\n";
let (out, tokens) = truncate_middle_with_token_budget(s, 8);
let (out, tokens) = truncate_middle_with_token_budget(s, /*max_tokens*/ 8);
assert_eq!(out, "😀😀😀😀…8 tokens truncated… line with text\n");
assert_eq!(tokens, Some(16));
}
@@ -66,6 +112,6 @@ fn truncate_middle_tokens_handles_utf8_content() {
#[test]
fn truncate_middle_bytes_handles_utf8_content() {
let s = "😀😀😀😀😀😀😀😀😀😀\nsecond line with text\n";
let out = truncate_middle_chars(s, 20);
let out = truncate_middle_chars(s, /*max_bytes*/ 20);
assert_eq!(out, "😀😀…21 chars truncated…with text\n");
}