Browse Source

Template for test class

Cameron Weinfurt 11 months ago
parent
commit
f4f4ecf176
1 changed files with 31 additions and 0 deletions
  1. 31
    0
      template_for_test_class.txt

+ 31
- 0
template_for_test_class.txt View File

@@ -0,0 +1,31 @@
1
+// EXPC means expected.
2
+
3
+public static class Test<name>{
4
+	public static void test(){
5
+		<name> testInstance = new <name>(<params>);
6
+
7
+		<data type> expectedValue<data member name> = EXPC;
8
+		...
9
+
10
+		testInstance.set<data member>(EXPC);
11
+		expectedValue<data member name> = EXPC;
12
+		if(testInstance.get<data member>() != expectedValue<data member> ||
13
+			 testInstance.get<next data member> != expectedValue<data member> ||
14
+			 ...){
15
+			throw new Exception("<name> unexpectedly changed!");
16
+		}
17
+		...
18
+
19
+		if(testInstance.<method name>(<params>) != EXPC) {
20
+			throw new Exception("<method name> in <name> gave unexpected results!");
21
+		}
22
+		expectedValue<data member name> = EXPC;
23
+		...
24
+		if(testInstance.get<data member>() != expectedValue<data member> ||
25
+			 testInstance.get<next data member> != expectedValue<data member> ||
26
+			 ...){
27
+			throw new Exception("<name> unexpectedly changed in <method name>!");
28
+		}
29
+		...
30
+	}
31
+}

Loading…
Cancel
Save