[JAVA-10384] Amendment to cover all cases + Added Unit tests (#12169)

Co-authored-by: panagiotiskakos <panagiotis.kakos@libra-is.com>
This commit is contained in:
panos-kakos 2022-05-05 16:59:28 +01:00 committed by GitHub
parent 2318e416a6
commit 078f635c45
3 changed files with 13 additions and 1 deletions

View File

@ -31,6 +31,6 @@ public class BalancedBracketsUsingDeque {
}
}
return true;
return deque.isEmpty();
}
}

View File

@ -49,6 +49,12 @@ public class BalancedBracketsUsingDequeUnitTest {
assertThat(result).isFalse();
}
@Test
public void givenAnotherEvenLengthUnbalancedString_whenCheckingForBalance_shouldReturnFalse() {
boolean result = balancedBracketsUsingDeque.isBalanced("{{}(");
assertThat(result).isFalse();
}
@Test
public void givenEvenLengthBalancedString_whenCheckingForBalance_shouldReturnTrue() {
boolean result = balancedBracketsUsingDeque.isBalanced("{[()]}");

View File

@ -49,6 +49,12 @@ public class BalancedBracketsUsingStringUnitTest {
assertThat(result).isFalse();
}
@Test
public void givenAnotherEvenLengthUnbalancedString_whenCheckingForBalance_shouldReturnFalse() {
boolean result = balancedBracketsUsingString.isBalanced("{{}(");
assertThat(result).isFalse();
}
@Test
public void givenEvenLengthBalancedString_whenCheckingForBalance_shouldReturnTrue() {
boolean result = balancedBracketsUsingString.isBalanced("{[()]}");