private void testBrackets(String str, boolean valid) throws IllegalAccessException {
        Stack<Character> stack = createCharStack();
        boolean isValid = true;
        try {
            for(int i = 0; i < str.length(); i++) {
                char a = str.charAt(i);
                switch(a) {
                    case '[':
                    case '{':
                    case '(':
                        stack.push(a);
                        break;
                    case ']':
                        validateStack(stack, '[');
                        break;
                    case ')':
                        validateStack(stack, '(');
                        break;
                    case '}':
                        validateStack(stack, '{');
                        break;
                }
            }
            isValid = stack.isEmpty();
        } catch(IllegalStateException e) {
            isValid = false;
        }
        assertEquals(valid, isValid);
    }