Skip to content

Add unit tests for the "Simple Bank System" problem. - #36

Merged
kobukuro merged 1 commit into
mainfrom
test/add-simple-bank-system-tests
Jan 11, 2026
Merged

kobukuro merged 1 commit into
mainfrom
test/add-simple-bank-system-tests

Conversation

@kobukuro

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings January 11, 2026 02:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds unit tests for the "Simple Bank System" problem (LeetCode #2043) and reorganizes the code structure by moving the Bank2043 class to the proper package location.

Changes:

  • Added comprehensive unit tests (Bank2043Test.java) with two test cases including edge cases from LeetCode examples
  • Moved Bank2043 class from src/ to src/main/java/com/leetcode/medium/ for proper package organization
  • Updated class structure with cleaner variable naming (balance → accounts) and removed redundant this keywords

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/main/java/com/leetcode/medium/Bank2043.java New implementation file with cleaner code structure, replacing the old file location
src/test/java/com/leetcode/medium/Bank2043Test.java New comprehensive test file with helper method and two test cases
src/Bank2043.java Old implementation file removed from incorrect location

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

Comment on lines +12 to +14
if (account1 > accounts.length || account2 > accounts.length) {
return false;
}

Copilot AI Jan 11, 2026

Copy link

Choose a reason for hiding this comment

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

The account validation is incomplete. It only checks if the account number exceeds the array length, but doesn't validate if the account number is less than 1. Account numbers should be valid positive integers (1-indexed). Add a check for account1 < 1 || account2 < 1 to prevent potential ArrayIndexOutOfBoundsException when accessing accounts[account1 - 1] or accounts[account2 - 1].

Copilot uses AI. Check for mistakes.
Comment on lines +24 to +25
if (account > accounts.length) {
return false;

Copilot AI Jan 11, 2026

Copy link

Choose a reason for hiding this comment

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

The account validation is incomplete. It only checks if the account number exceeds the array length, but doesn't validate if the account number is less than 1. Account numbers should be valid positive integers (1-indexed). Add a check for account < 1 to prevent potential ArrayIndexOutOfBoundsException when accessing accounts[account - 1].

Copilot uses AI. Check for mistakes.
Comment on lines +32 to +33
if (account > accounts.length) {
return false;

Copilot AI Jan 11, 2026

Copy link

Choose a reason for hiding this comment

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

The account validation is incomplete. It only checks if the account number exceeds the array length, but doesn't validate if the account number is less than 1. Account numbers should be valid positive integers (1-indexed). Add a check for account < 1 to prevent potential ArrayIndexOutOfBoundsException when accessing accounts[account - 1].

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +55
@Test
void testExample1() {
call(
new String[]{"Bank", "withdraw", "transfer", "deposit", "transfer", "withdraw"},
new Object[][]{
new Object[]{new long[]{10, 100, 20, 50, 30}},
new Object[]{3, 10},
new Object[]{5, 1, 20},
new Object[]{5, 20},
new Object[]{3, 4, 15},
new Object[]{10, 50}
},
new Object[]{null, true, true, true, false, false}
);
}

Copilot AI Jan 11, 2026

Copy link

Choose a reason for hiding this comment

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

The test suite lacks coverage for edge cases, particularly invalid account numbers. Consider adding test cases for scenarios such as: account numbers that are 0, negative values, or exceed the number of accounts. These edge cases would help ensure the validation logic handles boundary conditions correctly.

Copilot uses AI. Check for mistakes.
@kobukuro
kobukuro merged commit 4637ad8 into main Jan 11, 2026
7 checks passed
@kobukuro
kobukuro deleted the test/add-simple-bank-system-tests branch January 11, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants