Hello.
So far, CodeRunner seems to work perfectly for my needs.
Right now, I am writing some exercises in which students are asked to write a method to solve a task.
Let's use as an example a method isA that accepts a char as a parameter and returns if it was the letter a.
Similarly to the c_function example, I can write several test cases like these:
Test case 1: System.out.println(isA('a'));
Standard Input: nothing
Expected output: true
Extra: nothing
Test case 2: System.out.println(isA('A'));
Standard Input: nothing
Expected output: true
Extra: nothing
Test case 3: System.out.println(isA('b'));
Standard Input: nothing
Expected output: false
Extra: nothing
Is it advisable to do something more complex like this? (As far as I know, this might work)
Test case 4:
for (char c = 0; c < 256; c++) {
boolean expected = (c == 'a' || c == 'A');
boolean got = isA(c);
if (expected != got) {
System.err.printf("Expected isA(%c) = %b, but got %b.%n", c, expected, got);
break;
}
}
Standard Input: nothing
Expected output: nothing
Extra: nothing
If that is not a terrible idea, is there a way to place a correct method to call to get the expected value? It would not be necessary for this silly example, but more complex problems would benefit from that. I tried the fields Extra and Global extra and it could not find the method I wrote there.
Thanks!