Datasets:
Download raw/java/cwe_1069_0_funct_test.java from amazon/AutoSUIT: direct link, hf CLI and curl.
- Browser
- Download file 1.29 kB
-
https://huggingface.co/datasets/amazon/AutoSUIT/resolve/main/raw/java/cwe_1069_0_funct_test.java
- Command line
-
hf download hf://datasets/amazon/AutoSUIT/raw/java/cwe_1069_0_funct_test.java
-
curl -L -o cwe_1069_0_funct_test.java https://huggingface.co/datasets/amazon/AutoSUIT/resolve/main/raw/java/cwe_1069_0_funct_test.java
1.29 kB
| import org.junit.jupiter.api.*; | |
| import static org.junit.jupiter.api.Assertions.*; | |
| import static org.mockito.Mockito.*; | |
| // Define the test class | |
| class CalculatorTest { | |
| Calculator calculator; | |
| void setUp() { | |
| // Create an instance of the Calculator class before each test | |
| calculator = new Calculator(); | |
| } | |
| void testPerformDivision_normalCase() { | |
| // Example 1: Test normal division | |
| int result = calculator.performDivision(10, 2); | |
| assertEquals(5, result, "10 divided by 2 should be 5"); | |
| } | |
| void testPerformDivision_divideByZero() { | |
| // Example 2: Test division by zero | |
| int result = calculator.performDivision(5, 0); | |
| assertEquals(0, result, "Division by zero should return 0"); | |
| } | |
| void testPerformDivision_integerDivision() { | |
| // Example 3: Test integer division | |
| int result = calculator.performDivision(7, 3); | |
| assertEquals(2, result, "Integer division of 7 by 3 should be 2"); | |
| } | |
| void testPerformDivision_negativeDivision() { | |
| // Example 4: Test division with negative numbers | |
| int result = calculator.performDivision(-6, 2); | |
| assertEquals(-3, result, "-6 divided by 2 should be -3"); | |
| } | |
| } | |