test: add empty string and unicode edge cases to ValueTest#8219
test: add empty string and unicode edge cases to ValueTest#8219jack-berg merged 5 commits intoopen-telemetry:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8219 +/- ##
=========================================
Coverage 90.31% 90.32%
Complexity 7653 7653
=========================================
Files 843 843
Lines 23066 23080 +14
Branches 2310 2312 +2
=========================================
+ Hits 20832 20846 +14
Misses 1516 1516
Partials 718 718 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
It would be extra-cool if you made this into a fuzz-test that would test a wider variety of possible inputs. I think there are examples of this in the codebase somewhere. (search for "fuzz") |
|
@jkwatson Thanks for the great suggestion! I've implemented a property-based fuzz test using JQF alongside the original deterministic tests. Let me know if you need any further adjustments! |
jack-berg
left a comment
There was a problem hiding this comment.
Just a nit about preferring parameterized test. Thanks for adding!
| String specialBase64 = Value.of(specialStr.getBytes(StandardCharsets.UTF_8)).asString(); | ||
| byte[] decodedSpecial = Base64.getDecoder().decode(specialBase64); | ||
| assertThat(new String(decodedSpecial, StandardCharsets.UTF_8)).isEqualTo(specialStr); | ||
| } |
There was a problem hiding this comment.
When testing repeated inputs / outputs, I prefer @ParameterizedTest style, e.g.: https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk/common/src/test/java/io/opentelemetry/sdk/common/internal/GlobUtilTest.java#L17-L57
More readable and less verbose, especially when adding more test cases
There was a problem hiding this comment.
I think we can probably remove this TODO
There was a problem hiding this comment.
Pull request overview
Adds additional coverage for Value.asString() when the underlying Value is created from UTF-8 bytes, targeting boundary/edge cases.
Changes:
- Replaces the previous single-case
valueByteAsStringtest with a parameterized test including an empty string and other string variants. - Adds a JQF/GuidedFuzzing-based fuzz test driver to validate byte<->base64<->byte round-tripping for random strings.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thank you for your contribution @Tusharika725! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. |
Description
Resolves an inline
TODOinValueTest.javato add more test cases.Added edge cases for the
valueByteAsString()method to ensure string encoding/decoding handles boundaries without data loss. Specifically added:All local tests pass.