Repository navigation
test(reference): close numeric-literal coverage gap #310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
seonghobae
merged 6 commits into
main
from
test/reference-numeric-literal-coverage-main-20260822
Aug 25, 2026
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cda0c1a
test(reference): cover numeric literal separators
seonghobae e4ef7ee
test(reference): cover mixed tenant references
seonghobae 6da6fff
docs(test): clarify numeric reference contract
seonghobae 7b5188d
Merge 6da6fff177cd301220f3522e39782a1934e04f1b into 8c6b433fc27678d77…
seonghobae 8d43c23
Merge branch 'main' into test/reference-numeric-literal-coverage-main…
seonghobae b633d37
Merge branch 'main' into test/reference-numeric-literal-coverage-main…
opencode-agent[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| //! Public-reference tests for numeric-looking identifiers. | ||
| //! | ||
| //! References made only from numeric characters and their punctuation or signs are rejected. | ||
| //! References that combine letters with numbers remain valid opaque identifiers and keep their | ||
| //! original spelling. | ||
|
|
||
| use psychometrics_commons_runtime::participant::{AccountLinkError, ParticipantRecord}; | ||
|
|
||
| #[test] | ||
| fn numeric_literal_spellings_fail_closed_across_supported_unicode_separators() { | ||
| let numeric_like_refs = [ | ||
| "123", | ||
| "+123", | ||
| "-123", | ||
| "1.23", | ||
| "1,234", | ||
| "1e3", | ||
| "1E3", | ||
| "١٢٣", | ||
| "١٢\u{066B}٣", | ||
| "١\u{066C}٢٣٤", | ||
| "123", | ||
| "12\u{FF0E}3", | ||
| "1\u{FF0C}234", | ||
| ]; | ||
|
|
||
| for invalid_ref in numeric_like_refs { | ||
| assert_eq!( | ||
| ParticipantRecord::new_anonymous(invalid_ref, "tenant_alpha", 1), | ||
| Err(AccountLinkError::InvalidReference), | ||
| "numeric-like participant reference should fail closed: {invalid_ref:?}", | ||
| ); | ||
| assert_eq!( | ||
| ParticipantRecord::new_anonymous("participant_alpha", invalid_ref, 1), | ||
| Err(AccountLinkError::InvalidReference), | ||
| "numeric-like tenant reference should fail closed: {invalid_ref:?}", | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn numeric_punctuation_remains_valid_inside_opaque_mixed_references() { | ||
| for valid_ref in [ | ||
| "participant-1", | ||
| "participant.1", | ||
| "participant,1", | ||
| "participant+1", | ||
| "participant_e1", | ||
| "participantE1", | ||
| ] { | ||
| let participant = ParticipantRecord::new_anonymous(valid_ref, "tenant_alpha", 1) | ||
| .expect("mixed opaque participant references remain valid"); | ||
| assert_eq!(participant.participant_ref(), valid_ref); | ||
|
|
||
| let tenant = ParticipantRecord::new_anonymous("participant_alpha", valid_ref, 1) | ||
| .expect("mixed opaque tenant references remain valid"); | ||
| assert_eq!(tenant.tenant_ref(), valid_ref); | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.