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

Co-authored-by: panagiotiskakos <[email protected]>
This commit is contained in:
panos-kakos
2022-05-05 21:29:28 +05:30
committed by GitHub
co-authored by panagiotiskakos
parent 2318e416a6
commit 078f635c45
3 changed files with 13 additions and 1 deletions
@@ -31,6 +31,6 @@ public class BalancedBracketsUsingDeque {
}
}
return true;
return deque.isEmpty();
}
}
@@ -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("{[()]}");
@@ -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("{[()]}");