blob: 9d6b791d9e9ce037b37716f567a766e5ff2f99de (
plain) (
blame)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.document.predicate;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
/**
* @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen Hult</a>
*/
public class BooleanPredicateTest {
@Test
public void requireThatFalseIsAValue() {
assertTrue(PredicateValue.class.isAssignableFrom(BooleanPredicate.class));
}
@Test
public void requireThatCloneIsImplemented() throws CloneNotSupportedException {
BooleanPredicate node1 = new BooleanPredicate(true);
BooleanPredicate node2 = node1.clone();
assertEquals(node1, node2);
assertNotSame(node1, node2);
}
@Test
public void requireThatHashCodeIsImplemented() {
assertEquals(new BooleanPredicate(true).hashCode(), new BooleanPredicate(true).hashCode());
assertEquals(new BooleanPredicate(false).hashCode(), new BooleanPredicate(false).hashCode());
}
@Test
public void requireThatEqualsIsImplemented() {
BooleanPredicate lhs = new BooleanPredicate(true);
assertTrue(lhs.equals(lhs));
assertFalse(lhs.equals(new Object()));
BooleanPredicate rhs = new BooleanPredicate(false);
assertFalse(lhs.equals(rhs));
rhs.setValue(true);
assertTrue(lhs.equals(rhs));
}
}
|