| Summary: | Incorrect hand type name of testcase "test_Mahjong_AllInTriplet" is displayed | ||
|---|---|---|---|
| Product: | Mahjong Calculator | Reporter: | Wong Jyu Fung <jfwong3-c> |
| Component: | Mahjong | Assignee: | Wong Jyu Fung <jfwong3-c> |
| Status: | RESOLVED FIXED | ||
| Severity: | minor | CC: | chleung374-c, himywong2-c, jonatngai3-c |
| Priority: | Normal | ||
| Version: | unspecified | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: | actual outcome for testcase "test_Mahjong_Fan3" | ||
(In reply to Wong Jyu Fung from comment #0) > Created attachment 19 [details] > actual outcome for testcase "test_Mahjong_Fan3" > Description: We discovered that the output of testcase - "test_Mahjong_Fan3" is incorrect. The output also include other hand type which should not be displayed. How to reproduce: 1. Input 14 tiles which can complete "All in Triplets" 2. Select Tab "Run", select option "Run" in the platform Eclipse Java Oxygen (version 3.0) Expected result: We expected the output only contain the hand type "All in Triplet", i.e. Is a legal hand. All in Triplet Actual result: (also refer to the attachment) The system also output another hand type "chicken hand" in front, i.e. Is a legal hand. Chicken handAll in Triplet Possible cause: The default legal hand in the system is "chicken hand".Therefore, we should modify the code - if the input set of tiles can complete any other hand types, "chicken hand" should be replaced and not to be displayed. There are 2 test cases found to have the same bugs
Please take a look of the following codes.
@Test
public void test_Mahjong_AllTriplets4() { //AllTriplets+Contain Mix Orphans(Integration Testing)
String[] input = new String[] {"T1", "T1", "T1", "S1", "S1", "S1",
"M9", "M9", "M9", "H1", "H1", "H1", "H5", "H5"};
Calculator calculator = new Calculator(input);
int point = calculator.getWinPoint();
assertEquals(4, point);
String name = calculator.getWinName();
assertEquals("chicken handAll in Triplet Mix Orphans ", name);
}
@Test
public void test_Mahjong_CommonHand1() { //Common Hand(Unit Testing)
String[] input = new String[] {"M1", "M2", "M3", "M1", "M2", "M3",
"T1", "T2", "T3", "S4", "S5", "S6", "T1", "T1"};
Calculator calculator = new Calculator(input);
int point = calculator.getWinPoint();
assertEquals(1, point);
String name = calculator.getWinName();
assertEquals("chicken handCommon Hand", name);
}
As the default of the name of the win hand name is "chicken hand" and also in most of the cases that All Triple would be added behind other's name, It excited the bug that "All Triplet" would be added behind "chicken hand" when the hand is only "All Triplet". To solve this bug, I changed the default win hand name to an empty string. After all the checking, when we know that the win hand does not have any points, It would return "chicken hand" at that time. Also, The "All Triplet" cases would only return the "All Triplet" instead of "Chick handAll Triplet". |
Created attachment 19 [details] actual outcome for testcase "test_Mahjong_Fan3" Description: We discovered that the output of testcase - "test_Mahjong_Fan3" is incorrect. The output also include other hand type which should not be displayed. How to reproduce: 1. Input 14 tiles which can complete "All in Triplets" 2. Tab "Run", select option "Run" Expected result: We expected the output only contain the hand type "All in Triplet", i.e. Is a legal hand. All in Triplet Actual result: (also refer to the attachment) The system also output another hand type "chicken hand" in front, i.e. Is a legal hand. Chicken handAll in Triplet Possible cause: The default legal hand in the system is "chicken hand".Therefore, we should modify the code - if the input set of tiles can complete any other hand types, "chicken hand" should be replaced and not to be displayed.