Search in sources :

Example 1 with RequiredFields

use of net.morimekta.test.providence.testing.RequiredFields in project providence by morimekta.

the class ProvidenceTest method testHashCode.

@Test
public void testHashCode() {
    OptionalFields of = OptionalFields.builder().build();
    OptionalFields of2 = OptionalFields.builder().build();
    RequiredFields rf = RequiredFields.builder().build();
    UnionFields uf = UnionFields.withCompactValue(new CompactFields("a", 4, null));
    assertThat(of, not(sameInstance(of2)));
    assertThat(of.hashCode(), is(equalTo(of2.hashCode())));
    assertThat(of.hashCode(), not(equalTo(rf.hashCode())));
    assertThat(uf.hashCode(), not(equalTo(rf.hashCode())));
}
Also used : UnionFields(net.morimekta.test.providence.testing.UnionFields) OptionalFields(net.morimekta.test.providence.testing.OptionalFields) RequiredFields(net.morimekta.test.providence.testing.RequiredFields) CompactFields(net.morimekta.test.providence.testing.CompactFields) Test(org.junit.Test)

Example 2 with RequiredFields

use of net.morimekta.test.providence.testing.RequiredFields in project providence by morimekta.

the class ProvidenceTest method testRequiredFields.

@Test
public void testRequiredFields() {
    RequiredFields rf = RequiredFields.builder().build();
    assertThat(rf.hasBooleanValue(), is(true));
    assertThat(rf.isBooleanValue(), is(false));
    assertThat(rf.hasByteValue(), is(true));
    assertThat(rf.getByteValue(), is((byte) 0));
    assertThat(rf.hasShortValue(), is(true));
    assertThat(rf.getShortValue(), is((short) 0));
    assertThat(rf.hasIntegerValue(), is(true));
    assertThat(rf.getIntegerValue(), is(0));
    assertThat(rf.hasLongValue(), is(true));
    assertThat(rf.getLongValue(), is(0L));
    assertThat(rf.hasDoubleValue(), is(true));
    assertThat(rf.getDoubleValue(), is(0.0));
    // null pointers, presence = false.
    assertThat(rf.hasStringValue(), is(true));
    assertThat(rf.getStringValue(), is(""));
    assertThat(rf.hasBinaryValue(), is(true));
    assertThat(rf.getBinaryValue(), is(Binary.empty()));
    assertThat(rf.hasEnumValue(), is(false));
    assertThat(rf.getEnumValue(), is(nullValue()));
    assertThat(rf.hasCompactValue(), is(false));
    assertThat(rf.getCompactValue(), is(nullValue()));
}
Also used : RequiredFields(net.morimekta.test.providence.testing.RequiredFields) Test(org.junit.Test)

Aggregations

RequiredFields (net.morimekta.test.providence.testing.RequiredFields)2 Test (org.junit.Test)2 CompactFields (net.morimekta.test.providence.testing.CompactFields)1 OptionalFields (net.morimekta.test.providence.testing.OptionalFields)1 UnionFields (net.morimekta.test.providence.testing.UnionFields)1