From 7c6d9cf0230030a5983eea34e56284bf9a00214a Mon Sep 17 00:00:00 2001 From: Yagimipreme Date: Mon, 22 Apr 2024 17:13:00 +0100 Subject: [PATCH 1/3] =?UTF-8?q?first=20gr=C3=BCn=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 14 ++++++++++++++ .vscode/settings.json | 3 +++ .../htw/berlin/prog2/ha1/CalculatorTest.java | 17 +++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..7c85317 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Current File", + "request": "launch", + "mainClass": "${file}" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7b016a8 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.compile.nullAnalysis.mode": "automatic" +} \ No newline at end of file diff --git a/app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java b/app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java index ddff0da..e0bfdba 100644 --- a/app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java +++ b/app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java @@ -90,5 +90,22 @@ void testMultipleDecimalDots() { //TODO hier weitere Tests erstellen + @Test + @DisplayName("Should display result after subtracting two positive numbers") + void testSubtract(){ + Calculator calc = new Calculator(); + + calc.pressDigitKey(3); + calc.pressBinaryOperationKey("-"); + calc.pressDigitKey(2); + calc.pressEqualsKey(); + + String expected = "1"; + String actual = calc.readScreen(); + + assertEquals(expected,actual); + } + + } From 32e3f50f63d103db7a0d2492bfc6eaf1e4e88874 Mon Sep 17 00:00:00 2001 From: Yagimipreme Date: Mon, 22 Apr 2024 17:29:29 +0100 Subject: [PATCH 2/3] erster roter test --- .../htw/berlin/prog2/ha1/CalculatorTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java b/app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java index e0bfdba..0c36e58 100644 --- a/app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java +++ b/app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java @@ -105,7 +105,25 @@ void testSubtract(){ assertEquals(expected,actual); } + //TODO hier rote tests erstellen + @Test + @DisplayName("Should respect punkt vor strich") + void shshshsh(){ + Calculator calc = new Calculator(); + + calc.pressDigitKey(4); + calc.pressBinaryOperationKey("+"); + calc.pressDigitKey(1); + calc.pressBinaryOperationKey("x"); + calc.pressDigitKey(5); + calc.pressEqualsKey(); + String expected = "9"; + String actual = calc.readScreen(); + + assertEquals(expected,actual); + + } } From 263d58b065da0d6435904e4900699cc5e61b5aeb Mon Sep 17 00:00:00 2001 From: Yagimipreme Date: Mon, 22 Apr 2024 17:35:54 +0100 Subject: [PATCH 3/3] zweiter roter test --- .../htw/berlin/prog2/ha1/CalculatorTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java b/app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java index 0c36e58..3655850 100644 --- a/app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java +++ b/app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java @@ -124,6 +124,28 @@ void shshshsh(){ assertEquals(expected,actual); } + @Test + @DisplayName("komplexe berechnung") + void asasdasdasd(){ + Calculator calc = new Calculator(); + + calc.pressDigitKey(1); + calc.pressDigitKey(0); + calc.pressBinaryOperationKey("+"); + calc.pressDigitKey(2); + calc.pressBinaryOperationKey("x"); + calc.pressDigitKey(6); + calc.pressBinaryOperationKey("/"); + calc.pressDigitKey(3); + calc.pressBinaryOperationKey("-"); + calc.pressDigitKey(5); + calc.pressEqualsKey(); + + String expected = "9"; + String actual = calc.readScreen(); + + assertEquals(expected, actual); + } }