Skip to content

Commit 0870429

Browse files
committed
cleanup/refactor/simplify
1 parent bf42978 commit 0870429

File tree

94 files changed

+586
-466
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+586
-466
lines changed

annotations/AtUnitComposition.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111

1212
public class AtUnitComposition {
1313
AtUnitExample1 testObject = new AtUnitExample1();
14-
@Test boolean tMethodOne() {
15-
return
16-
testObject.methodOne().equals("This is methodOne");
14+
@Test
15+
boolean tMethodOne() {
16+
return testObject.methodOne()
17+
.equals("This is methodOne");
1718
}
18-
@Test boolean tMethodTwo() {
19+
@Test
20+
boolean tMethodTwo() {
1921
return testObject.methodTwo() == 2;
2022
}
2123
}

annotations/AtUnitExample1.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,19 @@ public int methodTwo() {
1616
System.out.println("This is methodTwo");
1717
return 2;
1818
}
19-
@Test boolean methodOneTest() {
19+
@Test
20+
boolean methodOneTest() {
2021
return methodOne().equals("This is methodOne");
2122
}
22-
@Test boolean m2() { return methodTwo() == 2; }
23-
@Test private boolean m3() { return true; }
23+
@Test
24+
boolean m2() { return methodTwo() == 2; }
25+
@Test
26+
private boolean m3() { return true; }
2427
// Shows output for failure:
25-
@Test boolean failureTest() { return false; }
26-
@Test boolean anotherDisappointment() {
28+
@Test
29+
boolean failureTest() { return false; }
30+
@Test
31+
boolean anotherDisappointment() {
2732
return false;
2833
}
2934
}

annotations/AtUnitExample2.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,20 @@ public int methodTwo() {
1818
System.out.println("This is methodTwo");
1919
return 2;
2020
}
21-
@Test void assertExample() {
21+
@Test
22+
void assertExample() {
2223
assert methodOne().equals("This is methodOne");
2324
}
24-
@Test void assertFailureExample() {
25+
@Test
26+
void assertFailureExample() {
2527
assert 1 == 2: "What a surprise!";
2628
}
27-
@Test void exceptionExample() throws IOException {
29+
@Test
30+
void exceptionExample() throws IOException {
2831
new FileInputStream("nofile.txt"); // Throws
2932
}
30-
@Test boolean assertAndReturn() {
33+
@Test
34+
boolean assertAndReturn() {
3135
// Assertion with message:
3236
assert methodTwo() == 2: "methodTwo must equal 2";
3337
return methodOne().equals("This is methodOne");

annotations/AtUnitExample3.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ public int methodTwo() {
1919
System.out.println("This is methodTwo");
2020
return 2;
2121
}
22-
@TestObjectCreate static AtUnitExample3 create() {
22+
@TestObjectCreate
23+
static AtUnitExample3 create() {
2324
return new AtUnitExample3(47);
2425
}
25-
@Test boolean initialization() { return n == 47; }
26-
@Test boolean methodOneTest() {
26+
@Test
27+
boolean initialization() { return n == 47; }
28+
@Test
29+
boolean methodOneTest() {
2730
return methodOne().equals("This is methodOne");
2831
}
29-
@Test boolean m2() { return methodTwo() == 2; }
32+
@Test
33+
boolean m2() { return methodTwo() == 2; }
3034
}
3135
/* Output:
3236
annotations.AtUnitExample3

annotations/AtUnitExample4.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,42 @@ public AtUnitExample4(String word) {
2020
}
2121
public String getWord() { return word; }
2222
public String scrambleWord() {
23-
List<Character> chars =
24-
Arrays.asList(
25-
ConvertTo.boxed(word.toCharArray()));
23+
List<Character> chars = Arrays.asList(
24+
ConvertTo.boxed(word.toCharArray()));
2625
Collections.shuffle(chars, rand);
2726
StringBuilder result = new StringBuilder();
2827
for(char ch : chars)
2928
result.append(ch);
3029
return result.toString();
3130
}
32-
@TestProperty static List<String> input =
31+
@TestProperty
32+
static List<String> input =
3333
Arrays.asList(theory.split(" "));
3434
@TestProperty
35-
static Iterator<String> words = input.iterator();
36-
@TestObjectCreate static AtUnitExample4 create() {
35+
static Iterator<String> words = input.iterator();
36+
@TestObjectCreate
37+
static AtUnitExample4 create() {
3738
if(words.hasNext())
3839
return new AtUnitExample4(words.next());
3940
else
4041
return null;
4142
}
42-
@Test boolean words() {
43+
@Test
44+
boolean words() {
4345
System.out.println("'" + getWord() + "'");
4446
return getWord().equals("are");
4547
}
46-
@Test boolean scramble1() {
48+
@Test
49+
boolean scramble1() {
4750
// Use specific seed to get verifiable results:
4851
rand = new Random(47);
4952
System.out.println("'" + getWord() + "'");
5053
String scrambled = scrambleWord();
5154
System.out.println(scrambled);
5255
return scrambled.equals("lAl");
5356
}
54-
@Test boolean scramble2() {
57+
@Test
58+
boolean scramble2() {
5559
rand = new Random(74);
5660
System.out.println("'" + getWord() + "'");
5761
String scrambled = scrambleWord();

annotations/AtUnitExample5.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ public AtUnitExample5(String text) {
1616
}
1717
@Override
1818
public String toString() { return text; }
19-
@TestProperty static PrintWriter output;
20-
@TestProperty static int counter;
21-
@TestObjectCreate static AtUnitExample5 create() {
19+
@TestProperty
20+
static PrintWriter output;
21+
@TestProperty
22+
static int counter;
23+
@TestObjectCreate
24+
static AtUnitExample5 create() {
2225
String id = Integer.toString(counter++);
2326
try {
2427
output = new PrintWriter("Test" + id + ".txt");
@@ -27,20 +30,23 @@ public AtUnitExample5(String text) {
2730
}
2831
return new AtUnitExample5(id);
2932
}
30-
@TestObjectCleanup static void
31-
cleanup(AtUnitExample5 tobj) {
33+
@TestObjectCleanup
34+
static void cleanup(AtUnitExample5 tobj) {
3235
System.out.println("Running cleanup");
3336
output.close();
3437
}
35-
@Test boolean test1() {
38+
@Test
39+
boolean test1() {
3640
output.print("test1");
3741
return true;
3842
}
39-
@Test boolean test2() {
43+
@Test
44+
boolean test2() {
4045
output.print("test2");
4146
return true;
4247
}
43-
@Test boolean test3() {
48+
@Test
49+
boolean test3() {
4450
output.print("test3");
4551
return true;
4652
}

annotations/AtUnitExternalTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111

1212
public class
1313
AtUnitExternalTest extends AtUnitExample1 {
14-
@Test boolean tMethodOne() {
14+
@Test
15+
boolean tMethodOne() {
1516
return methodOne().equals("This is methodOne");
1617
}
17-
@Test boolean tMethodTwo() {
18+
@Test
19+
boolean tMethodTwo() {
1820
return methodTwo() == 2;
1921
}
2022
}

annotations/HashSetTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111

1212
public class HashSetTest {
1313
HashSet<String> testObject = new HashSet<>();
14-
@Test void initialization() {
14+
@Test
15+
void initialization() {
1516
assert testObject.isEmpty();
1617
}
17-
@Test void tContains() {
18+
@Test
19+
void tContains() {
1820
testObject.add("one");
1921
assert testObject.contains("one");
2022
}
21-
@Test void tRemove() {
23+
@Test
24+
void tRemove() {
2225
testObject.add("one");
2326
testObject.remove("one");
2427
assert testObject.isEmpty();

annotations/StackLStringTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@
1111

1212
public class
1313
StackLStringTest extends StackL<String> {
14-
@Test void tPush() {
14+
@Test
15+
void tPush() {
1516
push("one");
1617
assert top().equals("one");
1718
push("two");
1819
assert top().equals("two");
1920
}
20-
@Test void tPop() {
21+
@Test
22+
void tPop() {
2123
push("one");
2224
push("two");
2325
assert pop().equals("two");
2426
assert pop().equals("one");
2527
}
26-
@Test void tTop() {
28+
@Test
29+
void tTop() {
2730
push("A");
2831
push("B");
2932
assert top().equals("B");

annotations/Testable.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ public class Testable {
99
public void execute() {
1010
System.out.println("Executing..");
1111
}
12-
@Test void testExecute() { execute(); }
12+
@Test
13+
void testExecute() { execute(); }
1314
}

0 commit comments

Comments
 (0)