unit test & packages
This commit is contained in:
parent
3e595922e6
commit
abe38e8416
14 changed files with 70 additions and 1 deletions
Binary file not shown.
BIN
Code/Steiner/packagesStuff/bin/tech/photofuel/util/Txt.class
Normal file
BIN
Code/Steiner/packagesStuff/bin/tech/photofuel/util/Txt.class
Normal file
Binary file not shown.
BIN
Code/Steiner/packagesStuff/src/App.class
Normal file
BIN
Code/Steiner/packagesStuff/src/App.class
Normal file
Binary file not shown.
|
@ -1,5 +1,8 @@
|
|||
public class App {
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("Hello, World!");
|
||||
// System.out.println(Txt.Left("Hello World", 5));
|
||||
// System.out.println(Txt.Left("Hello World", -2));
|
||||
// System.out.println(Txt.Left("Hello World", 122));
|
||||
// System.out.println(Txt.Left("Hello World", 0));
|
||||
}
|
||||
}
|
||||
|
|
BIN
Code/Steiner/packagesStuff/src/tech/photofuel/util/Txt.class
Normal file
BIN
Code/Steiner/packagesStuff/src/tech/photofuel/util/Txt.class
Normal file
Binary file not shown.
16
Code/Steiner/packagesStuff/src/tech/photofuel/util/Txt.java
Normal file
16
Code/Steiner/packagesStuff/src/tech/photofuel/util/Txt.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package tech.photofuel.util;
|
||||
|
||||
public class Txt {
|
||||
public static String Left(String text, int anzahlZeichen) {
|
||||
try {
|
||||
if (text.length() < anzahlZeichen) {
|
||||
return text;
|
||||
} else {
|
||||
return text.substring(0, anzahlZeichen);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Invalid input error: " + e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
7
Code/Steiner/unitTest/.vscode/settings.json
vendored
Normal file
7
Code/Steiner/unitTest/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"java.project.sourcePaths": ["src"],
|
||||
"java.project.outputPath": "bin",
|
||||
"java.project.referencedLibraries": [
|
||||
"lib/**/*.jar"
|
||||
]
|
||||
}
|
18
Code/Steiner/unitTest/README.md
Normal file
18
Code/Steiner/unitTest/README.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
## Getting Started
|
||||
|
||||
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
|
||||
|
||||
## Folder Structure
|
||||
|
||||
The workspace contains two folders by default, where:
|
||||
|
||||
- `src`: the folder to maintain sources
|
||||
- `lib`: the folder to maintain dependencies
|
||||
|
||||
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
|
||||
|
||||
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
|
||||
|
||||
## Dependency Management
|
||||
|
||||
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
|
BIN
Code/Steiner/unitTest/bin/App.class
Normal file
BIN
Code/Steiner/unitTest/bin/App.class
Normal file
Binary file not shown.
BIN
Code/Steiner/unitTest/bin/AppTest.class
Normal file
BIN
Code/Steiner/unitTest/bin/AppTest.class
Normal file
Binary file not shown.
BIN
Code/Steiner/unitTest/lib/hamcrest-core-1.3.jar
Normal file
BIN
Code/Steiner/unitTest/lib/hamcrest-core-1.3.jar
Normal file
Binary file not shown.
BIN
Code/Steiner/unitTest/lib/junit-4.13.2.jar
Normal file
BIN
Code/Steiner/unitTest/lib/junit-4.13.2.jar
Normal file
Binary file not shown.
10
Code/Steiner/unitTest/src/App.java
Normal file
10
Code/Steiner/unitTest/src/App.java
Normal file
|
@ -0,0 +1,10 @@
|
|||
public class App {
|
||||
public static void main(String[] args) {
|
||||
App rechteckRechner = new App();
|
||||
System.out.println(rechteckRechner.calcUmfang(4.3, 5.7));
|
||||
}
|
||||
|
||||
public double calcUmfang(double seiteA, double seiteB) {
|
||||
return 2 * seiteA + 2 * seiteB;
|
||||
}
|
||||
}
|
15
Code/Steiner/unitTest/src/AppTest.java
Normal file
15
Code/Steiner/unitTest/src/AppTest.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class AppTest {
|
||||
@Test
|
||||
public void testCalcUmfang() {
|
||||
App calculation = new App();
|
||||
|
||||
assertEquals(-21, calculation.calcUmfang(-5, -5), 0.1);
|
||||
assertEquals("0", calculation.calcUmfang(0, 0), 0.1);
|
||||
assertEquals(2001000, calculation.calcUmfang(100000, 0), 0.1);
|
||||
assertEquals(10, calculation.calcUmfang(-2, 7), 0.1);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue