78 lines
1.9 KiB
Java
78 lines
1.9 KiB
Java
|
package de.hs_mannheim.informatik.spreadsheet;
|
||
|
|
||
|
import org.junit.jupiter.api.Test;
|
||
|
|
||
|
import static org.junit.jupiter.api.Assertions.*;
|
||
|
|
||
|
class SpreadsheetTest {
|
||
|
|
||
|
@Test
|
||
|
void calculateTheSumOfNumbers(){
|
||
|
Spreadsheet eingabe = new Spreadsheet(99, 26);
|
||
|
|
||
|
eingabe.put("T5", "=13+6");
|
||
|
assertEquals("19", eingabe.get("T5"));
|
||
|
|
||
|
eingabe.put("T6", "=0+0");
|
||
|
assertEquals("0", eingabe.get("T6"));
|
||
|
|
||
|
eingabe.put("T7", "=22+34");
|
||
|
assertEquals("56", eingabe.get("T7"));
|
||
|
|
||
|
eingabe.put("T8", "= 9 + 3");
|
||
|
assertEquals("12", eingabe.get("T8"));
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
void calculateTheDifOfNumbers(){
|
||
|
Spreadsheet eingabe = new Spreadsheet(99, 26);
|
||
|
|
||
|
eingabe.put("T5", "=13-6");
|
||
|
assertEquals("7", eingabe.get("T5"));
|
||
|
|
||
|
eingabe.put("T6", "=0-0");
|
||
|
assertEquals("0", eingabe.get("T6"));
|
||
|
|
||
|
eingabe.put("T7", "=22-34");
|
||
|
assertEquals("-12", eingabe.get("T7"));
|
||
|
|
||
|
eingabe.put("T8", "= 9 - 3");
|
||
|
assertEquals("6", eingabe.get("T8"));
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
void calculateTheProdOfNumbers(){
|
||
|
Spreadsheet eingabe = new Spreadsheet(99, 26);
|
||
|
|
||
|
eingabe.put("T5", "=13*6");
|
||
|
assertEquals("78", eingabe.get("T5"));
|
||
|
|
||
|
eingabe.put("T6", "=0*0");
|
||
|
assertEquals("0", eingabe.get("T6"));
|
||
|
|
||
|
eingabe.put("T7", "=-2*34");
|
||
|
assertEquals("-68", eingabe.get("T7"));
|
||
|
|
||
|
eingabe.put("T8", "= 9 * 3");
|
||
|
assertEquals("27", eingabe.get("T8"));
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
void calculateTheValueOfQuotOfNumbers(){
|
||
|
Spreadsheet eingabe = new Spreadsheet(99, 26);
|
||
|
|
||
|
eingabe.put("T5", "=12/3");
|
||
|
assertEquals("4", eingabe.get("T5"));
|
||
|
|
||
|
eingabe.put("T6", "=5/0");
|
||
|
assertEquals("exc.", eingabe.get("T6"));
|
||
|
|
||
|
eingabe.put("T7", "= 22 / 2");
|
||
|
assertEquals("11", eingabe.get("T7"));
|
||
|
|
||
|
eingabe.put("T8", "= 0 / 5");
|
||
|
assertEquals("0", eingabe.get("T8"));
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|