test: harden RangeValue::extract_str test with derived indices and UTF-8 coverage#85
test: harden RangeValue::extract_str test with derived indices and UTF-8 coverage#85bashandbone merged 4 commits intomainfrom
RangeValue::extract_str test with derived indices and UTF-8 coverage#85Conversation
This adds a comprehensive test in `recoco-core/src/base/value.rs` to verify that `RangeValue::extract_str` functions correctly. The test covers basic string extraction, extraction using string references, empty string extraction, and bounds extraction. Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a unit test for RangeValue::extract_str (as requested in feedback on #72) to validate basic extraction behavior over common ranges.
Changes:
- Added
test_range_value_extract_strcovering start, middle, empty, and full-range extraction - Verified
AsRef<str>usage by testing against both&strandString
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
crates/recoco-core/src/base/value.rs
Outdated
| let range = RangeValue::new(0, 5); | ||
| assert_eq!(range.extract_str(text), "hello"); | ||
|
|
||
| // Extraction from middle | ||
| let range = RangeValue::new(6, 11); | ||
| assert_eq!(range.extract_str(text), "world"); | ||
|
|
||
| // Extraction using String (AsRef<str>) | ||
| let string_text = String::from("hello world"); | ||
| let range = RangeValue::new(0, 5); | ||
| assert_eq!(range.extract_str(&string_text), "hello"); | ||
|
|
||
| // Empty extraction | ||
| let range = RangeValue::new(5, 5); | ||
| assert_eq!(range.extract_str(text), ""); | ||
|
|
||
| // Full extraction | ||
| let range = RangeValue::new(0, 11); |
crates/recoco-core/src/base/value.rs
Outdated
| // Basic extraction | ||
| let range = RangeValue::new(0, 5); | ||
| assert_eq!(range.extract_str(text), "hello"); | ||
|
|
||
| // Extraction from middle | ||
| let range = RangeValue::new(6, 11); | ||
| assert_eq!(range.extract_str(text), "world"); | ||
|
|
||
| // Extraction using String (AsRef<str>) | ||
| let string_text = String::from("hello world"); | ||
| let range = RangeValue::new(0, 5); | ||
| assert_eq!(range.extract_str(&string_text), "hello"); | ||
|
|
||
| // Empty extraction | ||
| let range = RangeValue::new(5, 5); | ||
| assert_eq!(range.extract_str(text), ""); | ||
|
|
||
| // Full extraction | ||
| let range = RangeValue::new(0, 11); |
| #[test] | ||
| fn test_range_value_extract_str() { | ||
| let text = "hello world"; | ||
|
|
||
| // Basic extraction | ||
| let range = RangeValue::new(0, 5); | ||
| assert_eq!(range.extract_str(text), "hello"); |
…TF-8 cases Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
recoco-docs | be3ac76 | Commit Preview URL Branch Preview URL |
Mar 13 2026, 04:41 AM |
RangeValue::extract_str test with derived indices and UTF-8 coverage
Signed-off-by: Adam Poulemanos <89049923+bashandbone@users.noreply.github.com>
|
🤖 Hi @Copilot, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
|
👋 Hey @Copilot, Thanks for your contribution to codeweaver! 🧵You need to agree to the CLA first... 🖊️Before we can accept your contribution, you need to agree to our Contributor License Agreement (CLA). To agree to the CLA, please comment:
Those exact words are important1, so please don't change them. 😉 You can read the full CLA here: Contributor License Agreement ✅ @Copilot has signed the CLA. You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. Footnotes
|
|
🤖 I'm sorry @Copilot, but I was unable to process your request. Please see the logs for more details. |
Review feedback on the original
test_range_value_extract_strtest identified two gaps: magic-number byte offsets tightly coupled to the literal string, and no multi-byte UTF-8 coverage.Changes
5,6,11) with values computed from the input —"hello".len(),text.find("world").unwrap(),text.find(' ').unwrap(),text.len()— so intent remains clear if the string changes."héllo wörld"(whereéandöare 2-byte sequences), verifying thatextract_str's byte-slice indexing is correct at multi-byte character boundaries.📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.