[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:
parent
2318e416a6
commit
078f635c45
|
@ -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("{[()]}");
|
||||
|
|
Loading…
Reference in New Issue