Skip to content

test: harden RangeValue::extract_str test with derived indices and UTF-8 coverage#85

Merged
bashandbone merged 4 commits intomainfrom
copilot/sub-pr-72
Mar 13, 2026
Merged

test: harden RangeValue::extract_str test with derived indices and UTF-8 coverage#85
bashandbone merged 4 commits intomainfrom
copilot/sub-pr-72

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 13, 2026

Review feedback on the original test_range_value_extract_str test identified two gaps: magic-number byte offsets tightly coupled to the literal string, and no multi-byte UTF-8 coverage.

Changes

  • Derived indices: Replaced all hard-coded offsets (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.
  • UTF-8 cases: Added assertions over "héllo wörld" (where é and ö are 2-byte sequences), verifying that extract_str's byte-slice indexing is correct at multi-byte character boundaries.
let utf8_text = "héllo wörld";
let utf8_hello_end = "héllo".len();           // 6, not 5
let utf8_world_start = utf8_text.find("wörld").unwrap();
let utf8_world_end = utf8_world_start + "wörld".len();

assert_eq!(RangeValue::new(0, utf8_hello_end).extract_str(utf8_text), "héllo");
assert_eq!(RangeValue::new(utf8_world_start, utf8_world_end).extract_str(utf8_text), "wörld");

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

google-labs-jules bot and others added 2 commits March 13, 2026 02:48
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>
Base automatically changed from add-test-for-rangevalue-extract-str-8573942695424897582 to main March 13, 2026 04:11
@bashandbone bashandbone marked this pull request as ready for review March 13, 2026 04:17
Copilot AI review requested due to automatic review settings March 13, 2026 04:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_str covering start, middle, empty, and full-range extraction
  • Verified AsRef<str> usage by testing against both &str and String

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1516 to +1533
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);
Comment on lines +1515 to +1533
// 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);
Comment on lines +1511 to +1517
#[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>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 13, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

Copilot AI changed the title [WIP] [8573942695424897582] Add test for RangeValue::extract_str test: harden RangeValue::extract_str test with derived indices and UTF-8 coverage Mar 13, 2026
Copilot AI requested a review from bashandbone March 13, 2026 04:23
Signed-off-by: Adam Poulemanos <89049923+bashandbone@users.noreply.github.com>
@bashandbone bashandbone merged commit 7d7e67a into main Mar 13, 2026
8 of 10 checks passed
@bashandbone bashandbone deleted the copilot/sub-pr-72 branch March 13, 2026 04:40
@github-actions
Copy link
Copy Markdown
Contributor

🤖 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.

@github-actions
Copy link
Copy Markdown
Contributor

👋 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:

I read the contributors license agreement and I agree to it.

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

  1. Our bot needs those exact words to recognize that you agree to the CLA.

@github-actions
Copy link
Copy Markdown
Contributor

🤖 I'm sorry @Copilot, but I was unable to process your request. Please see the logs for more details.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants