summaryrefslogtreecommitdiff
path: root/src/test/java/au/id/zancanaro/javacheck/object/MyObjectAddTest.java
blob: 7965449c1d55ed5bf1c262ce864faf78f7f5c4b5 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package au.id.zancanaro.javacheck.object;

import au.id.zancanaro.javacheck.Generator;
import au.id.zancanaro.javacheck.annotations.DataSource;
import au.id.zancanaro.javacheck.annotations.Property;
import au.id.zancanaro.javacheck.junit.Properties;
import org.junit.runner.RunWith;

import java.util.Collections;

import static au.id.zancanaro.javacheck.Generators.ofType;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

@RunWith(Properties.class)
public class MyObjectAddTest {

    @DataSource
    public static Generator<MyObject> source = ofType(MyObject.class);

    @Property
    public void testAdd(MyObject a, MyObject b) {
        MyObject added = a.add(b);
        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));
    }

}