feat: add comprehensive tests for built-in string functions#47
Merged
feat: add comprehensive tests for built-in string functions#47
Conversation
7eab311 to
5dc7896
Compare
- Add 21 integration tests in tests/string_functions.rs covering all TDD scenarios from the issue: join, split, lower, upper, trim, replace, len, coalesce, error handling, and composability - Extend join() to support variadic string concatenation (join(a, b, c)) in addition to array join(arr, sep) - Add unit tests for edge cases: split no-match, lower already-lower, trim no-spaces, replace all occurrences, len empty string, coalesce first-non-null, lower with non-string coercion - Fix clippy warnings: redundant closure, single_match, approx_constant Fixes #18
5dc7896 to
4a27789
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds comprehensive test coverage for all built-in string functions specified in #18, along with a small enhancement to
join()and clippy fixes.Changes
New integration tests (
tests/string_functions.rs— 21 tests):Covers every TDD scenario from the issue:
join("a", "b", "c")→"abc"(variadic string concat)join(.first, " ", .last)with field valuesjoin(.tags, ",")array join with separatorsplit("a,b,c", ",")→["a", "b", "c"]split("hello", "x")→["hello"](no match)lower("HELLO")→"hello"lower("Already lower")→"already lower"upper("hello")→"HELLO"trim(" hello ")→"hello"trim("no-spaces")→"no-spaces"replace("hello world", "world", "rust")→"hello rust"replace("aaa", "a", "b")→"bbb"(all occurrences)len("hello")→5,len([1,2,3])→3,len("")→0coalesce(null, null, "found")→"found"coalesce("first", "second")→"first"coalesce(.missing, .name)→ fallback to existing fieldlower(trim(...)),upper(replace(...))Enhanced
join()function:join("a", "b", "c")→"abc"join(["a","b"], ",")→"a,b"Additional unit tests in
functions.rs:split_no_match,lower_already_lower,lower_non_string_coercestrim_no_spaces,replace_all_occurrences,len_empty_string,len_array_3coalesce_first_non_null,join_strings,join_with_field_valuesClippy fixes:
matchsingle-pattern withif letapprox_constantwarnings (3.14 → 3.15 in tests)Fixes #18