private void testCode(String code, int... expectedOutput) {
        runner.run(code);

        final String output = baos.toString();

        assertEquals(expectedOutput.length, output.length());
        for (int i = 0; i < output.length(); i++) {
            assertEquals(expectedOutput[i], output.charAt(i));
        }
    }