Skip to content

Commit f2b6b4e

Browse files
Test Userclaude
andcommitted
test(terraphim_server): fix orphaned floor_char_boundary tests to use stdlib method
Commit bf8fe06 (PR #2841) deleted the private polyfill fn floor_char_boundary from terraphim_server/src/lib.rs, but 6a303c6 (PR #2846) then added 8 unit tests that still called floor_char_boundary(s, n) as the deleted free function. cargo test -p terraphim_server failed to compile with 15x E0425. Production code at line 119 already uses the stdlib method combined.floor_char_boundary(397) (stable since MSRV 1.91.0). Rewrite the 8 orphaned tests to call s.floor_char_boundary(n) the same way, preserving the boundary-algorithm regression coverage that create_document_description depends on. Verified: cargo test -p terraphim_server --lib -> 23 passed; cargo clippy -p terraphim_server -- -D warnings -> exit 0. Refs #2811 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4966835 commit f2b6b4e

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

terraphim_server/src/lib.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -633,67 +633,67 @@ async fn not_found() -> Response {
633633
mod tests {
634634
use super::*;
635635

636-
// --- floor_char_boundary ---
636+
// --- floor_char_boundary (stdlib str::floor_char_boundary, stable since MSRV 1.91.0) ---
637637

638638
#[test]
639639
fn floor_char_boundary_index_beyond_len_returns_len() {
640640
let s = "hello";
641-
assert_eq!(floor_char_boundary(s, 100), s.len());
641+
assert_eq!(s.floor_char_boundary(100), s.len());
642642
}
643643

644644
#[test]
645645
fn floor_char_boundary_index_equal_to_len_returns_len() {
646646
let s = "hello";
647-
assert_eq!(floor_char_boundary(s, 5), 5);
647+
assert_eq!(s.floor_char_boundary(5), 5);
648648
}
649649

650650
#[test]
651651
fn floor_char_boundary_index_at_valid_ascii_boundary() {
652652
let s = "hello";
653-
assert_eq!(floor_char_boundary(s, 3), 3);
653+
assert_eq!(s.floor_char_boundary(3), 3);
654654
}
655655

656656
#[test]
657657
fn floor_char_boundary_zero_index_returns_zero() {
658658
let s = "hello";
659-
assert_eq!(floor_char_boundary(s, 0), 0);
659+
assert_eq!(s.floor_char_boundary(0), 0);
660660
}
661661

662662
#[test]
663663
fn floor_char_boundary_empty_string_returns_zero() {
664-
assert_eq!(floor_char_boundary("", 0), 0);
665-
assert_eq!(floor_char_boundary("", 5), 0);
664+
assert_eq!("".floor_char_boundary(0), 0);
665+
assert_eq!("".floor_char_boundary(5), 0);
666666
}
667667

668668
#[test]
669669
fn floor_char_boundary_multibyte_char_at_boundary() {
670670
// "é" encodes as 2 bytes: [0xC3, 0xA9]; "aé".len() == 3
671671
let s = "aé";
672-
assert_eq!(floor_char_boundary(s, 1), 1); // byte 1 = start of 'é' — valid
673-
assert_eq!(floor_char_boundary(s, 2), 1); // byte 2 = inside 'é' — retreat to 1
674-
assert_eq!(floor_char_boundary(s, 3), 3); // index >= len — returns len
672+
assert_eq!(s.floor_char_boundary(1), 1); // byte 1 = start of 'é' — valid
673+
assert_eq!(s.floor_char_boundary(2), 1); // byte 2 = inside 'é' — retreat to 1
674+
assert_eq!(s.floor_char_boundary(3), 3); // index >= len — returns len
675675
}
676676

677677
#[test]
678678
fn floor_char_boundary_inside_multibyte_char_retreats() {
679679
// CJK character '中' encodes as 3 bytes: [0xE4, 0xB8, 0xAD]
680680
let s = "a中b";
681681
// byte index 2 and 3 are inside '中', so floor should return 1 (the 'a' boundary)
682-
assert_eq!(floor_char_boundary(s, 2), 1);
683-
assert_eq!(floor_char_boundary(s, 3), 1);
682+
assert_eq!(s.floor_char_boundary(2), 1);
683+
assert_eq!(s.floor_char_boundary(3), 1);
684684
// byte index 4 is the start of 'b', valid boundary
685-
assert_eq!(floor_char_boundary(s, 4), 4);
685+
assert_eq!(s.floor_char_boundary(4), 4);
686686
}
687687

688688
#[test]
689689
fn floor_char_boundary_emoji_inside_retreats() {
690690
// "🦀" encodes as 4 bytes
691691
let s = "x🦀y";
692692
// byte indices 2 and 3 are inside the emoji (starts at 1)
693-
assert_eq!(floor_char_boundary(s, 2), 1);
694-
assert_eq!(floor_char_boundary(s, 3), 1);
693+
assert_eq!(s.floor_char_boundary(2), 1);
694+
assert_eq!(s.floor_char_boundary(3), 1);
695695
// byte index 5 is the start of 'y'
696-
assert_eq!(floor_char_boundary(s, 5), 5);
696+
assert_eq!(s.floor_char_boundary(5), 5);
697697
}
698698

699699
// --- create_document_description ---

0 commit comments

Comments
 (0)