Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package a03.a;
- import junit.framework.TestCase;
- public class AMethodTest extends TestCase {
- public static final int OptionOne = 1;
- public static final int OptionTwo = 2;
- public void testAMethod() {
- assertAMethodResultEquals(OptionOne, false, false, false);
- assertAMethodResultEquals(OptionOne, false, false, true);
- assertAMethodResultEquals(OptionOne, false, true, false);
- assertAMethodResultEquals(OptionOne, false, true, true);
- assertAMethodResultEquals(OptionTwo, true, false, false);
- assertAMethodResultEquals(OptionTwo, true, false, true);
- assertAMethodResultEquals(OptionTwo, true, true, false);
- assertAMethodResultEquals(OptionOne, true, true, true);
- }
- private void assertAMethodResultEquals(int expectedReturnOptionValue, boolean first, boolean second, boolean third) {
- final int actualResultValue = this.AMethod(first, second, third);
- final String methodCallMsg = "AMethod(" + first + ", " + second + ", " + third + ")";
- assertEquals(methodCallMsg + ";", expectedReturnOptionValue, actualResultValue);
- }
- public int AMethod(boolean first, boolean second, boolean third) {
- if (!first) {
- if (second) {
- if (third) {
- return OptionOne;
- } else if (!second) {
- return OptionTwo;
- } else {
- return OptionOne;
- }
- } else {
- return OptionOne;
- }
- } else if (!third) {
- if (!second) {
- return OptionTwo;
- }
- } else if (!second) {
- return OptionTwo;
- }
- if (!(third || !second)) {
- return OptionTwo;
- }
- return OptionOne;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement