From 69c01f6bec21c25fb45725540a2b0be3a672962c Mon Sep 17 00:00:00 2001 From: selim Date: Thu, 28 Dec 2023 01:36:37 +0100 Subject: [PATCH] JUnit5 function tests done. --- Axel/resources/zahlen.csv | 19 +- .../informatik/spreadsheet/Axel.java | 2 +- .../informatik/spreadsheet/Cell.java | 2 +- .../informatik/spreadsheet/Spreadsheet.java | 2 +- .../spreadsheet/SpreadsheetTest.java | 192 +++++++++++++++++- 5 files changed, 203 insertions(+), 14 deletions(-) diff --git a/Axel/resources/zahlen.csv b/Axel/resources/zahlen.csv index 9167e5d..5bce6de 100644 --- a/Axel/resources/zahlen.csv +++ b/Axel/resources/zahlen.csv @@ -1,9 +1,10 @@ -=2,,,=SUMME(A1:A6),,,,,,,, -,,,,,,,,,,, -,,,,,,,,,,, -,,,,,,,,,,, -,,,,,,,,,,, -,,,,,,,,,,, -,,,,,,,,,,, -,,,,,,,,,,, -,,,,,,,,,,, +=MITTELWERT(B1:C10),=10,=234,,,,,,, +,,,,,,,,, +,,,,,,,,, +,,,,,,,,, +,,,,,,,,, +,,,,,,,,, +,,,,,,,,, +,,,,,,,,, +,,,,,,,,, +,,,,,,,,, diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java index f684c00..46d1b7d 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java @@ -7,7 +7,7 @@ import java.util.Scanner; /** * Part of a simplified spreadsheet system for the PR1 programming lab at Hochschule Mannheim. * - * @author Oliver Hummel + * @author Oliver Hummel, Selim Eser (2211482) */ public class Axel { diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Cell.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Cell.java index f80e156..b02a610 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Cell.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Cell.java @@ -4,7 +4,7 @@ package de.hs_mannheim.informatik.spreadsheet; * Part of a simplified spreadsheet system for the PR1 programming lab at Hochschule Mannheim. * A cell needs to be able to hold a formula and a value * - * @author Oliver Hummel + * @author Oliver Hummel, Selim Eser (2211482) */ public class Cell { private String formula = ""; diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java index 9166bfd..fcf8845 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java @@ -14,7 +14,7 @@ import java.util.regex.Pattern; * A simplified spreadsheet class for the PR1 programming lab at Hochschule Mannheim. * One aspect worth mentioning is that it only supports long numbers, not doubles. * - * @author Selim Eser (2211482) + * @author Oliver Hummel, Selim Eser (2211482) */ public class Spreadsheet { Cell[][] cells; diff --git a/Axel/test/de/hs_mannheim/informatik/spreadsheet/SpreadsheetTest.java b/Axel/test/de/hs_mannheim/informatik/spreadsheet/SpreadsheetTest.java index f6ac17e..8d73a4e 100644 --- a/Axel/test/de/hs_mannheim/informatik/spreadsheet/SpreadsheetTest.java +++ b/Axel/test/de/hs_mannheim/informatik/spreadsheet/SpreadsheetTest.java @@ -1,10 +1,198 @@ package de.hs_mannheim.informatik.spreadsheet; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import static org.junit.jupiter.api.Assertions.*; class SpreadsheetTest { - @org.junit.jupiter.api.Test - void sum() { + String[][] cells = {{"1","2"},{"2","4"},{"3","6"}}; + + @Test + void sumTest() { + + double result = 0; + + for(int r = 0; r0) + result *= Double.parseDouble(cells[r][c]); + else { + result = Double.parseDouble(cells[r][c]); + counter++; + } + assertEquals(288,result); + } + @Test + void averageTest() { + + double result = 0; + int counter = 0; + + for(int r = 0; r cellNames = new ArrayList<>(); + + double result = 0; + double avg = 0; + int counter = 0; + for(int r = 0; r copyCellNames = new ArrayList<>(cellNames); + double[] frequency = new double[cellNames.size()]; + Arrays.fill(frequency,1); + ArrayList relativeFrequency = new ArrayList<>(); + double mem = 0; + + for(int i = 0; i< cellNames.size(); i++) { + for(int t = 0; t cellNames = new ArrayList<>(); + + for(int r = 0; r< cells.length; r++) + for(int c = 0; c Double.parseDouble(cellNames.get(i))) + result = Double.parseDouble(cellNames.get(i)); + + assertEquals(1,result); + } + @Test + void maxTest() { + ArrayList cellNames = new ArrayList<>(); + + for(int r = 0; r< cells.length; r++) + for(int c = 0; c