Skip to content

Handle zero input in expandedForm - #105

Closed
krotname wants to merge 1 commit into
mainfrom
codex/fix-crash-for-zero-input-in-expandedform
Closed

Handle zero input in expandedForm#105
krotname wants to merge 1 commit into
mainfrom
codex/fix-crash-for-zero-input-in-expandedform

Conversation

@krotname

@krotname krotname commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Calling expandedForm(0) produced an empty buffer and then substring(0, result.length() - 3), causing a StringIndexOutOfBoundsException, so the helper must handle zero robustly.

Description

  • Return "0" immediately when expandedForm(int num) is invoked with num == 0, preserving existing behavior for other inputs in src/main/java/kyu6/NumberInExpandedForm.java.
  • Add a regression test zeroShouldRemainZero in src/test/java/kyu6/NumberInExpandedFormTest.java that asserts expandedForm(0) returns "0".

Testing

  • Ran mvn -Dtest=NumberInExpandedFormTest test which executed the class-specific tests and they passed (2 tests, 0 failures).
  • Ran full test suite with mvn test and all automated tests passed (598 tests, 0 failures or errors).

Codex Task

@krotname

krotname commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

Superseded by the validated combined merge in #115: #115

@krotname krotname closed this Aug 1, 2026
@krotname
krotname deleted the codex/fix-crash-for-zero-input-in-expandedform branch August 1, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant