summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@zancanaro.id.au>2015-06-10 00:21:35 +1000
committerCarlo Zancanaro <carlo@zancanaro.id.au>2015-06-10 00:21:35 +1000
commit60bc9218d0872e40a6857706d51955ee3d058717 (patch)
treeb6032a73a629ffe6027dda34433d4ea972e5537f /src/test
parent6546881559e4bbcfe2b220199a9f3cd4196d1960 (diff)
Support enums in the ObjectGeneration stuff
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/au/id/zancanaro/javacheck/object/MyObjectAddTest.java1
-rw-r--r--src/test/java/au/id/zancanaro/javacheck/object/SubObject.java16
2 files changed, 12 insertions, 5 deletions
diff --git a/src/test/java/au/id/zancanaro/javacheck/object/MyObjectAddTest.java b/src/test/java/au/id/zancanaro/javacheck/object/MyObjectAddTest.java
index 9321acb..884114c 100644
--- a/src/test/java/au/id/zancanaro/javacheck/object/MyObjectAddTest.java
+++ b/src/test/java/au/id/zancanaro/javacheck/object/MyObjectAddTest.java
@@ -16,6 +16,7 @@ public class MyObjectAddTest {
assertTrue(added.string.length() == a.string.length() + b.string.length());
assertTrue(added.value == a.value + b.value);
assertEquals(added.subObject, a.subObject.add(b.subObject));
+ assertEquals(added.subObject.value, a.subObject.value);
}
}
diff --git a/src/test/java/au/id/zancanaro/javacheck/object/SubObject.java b/src/test/java/au/id/zancanaro/javacheck/object/SubObject.java
index bdf2ce8..1e49cfe 100644
--- a/src/test/java/au/id/zancanaro/javacheck/object/SubObject.java
+++ b/src/test/java/au/id/zancanaro/javacheck/object/SubObject.java
@@ -4,9 +4,11 @@ import java.util.*;
public class SubObject<T> {
public final Map<String, List<T>> obj;
+ public final EnumValues value;
- public SubObject(Map<String, List<T>> obj) {
+ public SubObject(Map<String, List<T>> obj, EnumValues value) {
this.obj = obj;
+ this.value = value;
}
public SubObject<T> add(SubObject<T> other) {
@@ -21,12 +23,12 @@ public class SubObject<T> {
values.put(key, entry.getValue());
}
}
- return new SubObject<>(Collections.unmodifiableMap(values));
+ return new SubObject<>(Collections.unmodifiableMap(values), this.value);
}
@Override
public String toString() {
- return obj.toString();
+ return "{" + obj.toString() + ", " + this.value + "}";
}
@Override
@@ -34,11 +36,15 @@ public class SubObject<T> {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SubObject subObject = (SubObject) o;
- return obj.equals(subObject.obj);
+ return obj.equals(subObject.obj) && value.equals(subObject.value);
}
@Override
public int hashCode() {
- return obj.hashCode();
+ return obj.hashCode() + 37 * value.hashCode();
+ }
+
+ public static enum EnumValues {
+ A, B, C
}
}