Refine search
/** * A shortcut to the frequently used <code>not(equalTo(x))</code>. * <p/> * For example: * <pre>assertThat(cheese, is(not(smelly)))</pre> * instead of: * <pre>assertThat(cheese, is(not(equalTo(smelly))))</pre> * * @param value * the value that any examined object should <b>not</b> equal */ @Factory public static <T> Matcher<T> not(T value) { return not(equalTo(value)); } }
@Test public void shouldComputeHashCodeForOnePrimitive() { assertThat(HashCode.compute(1), is(not(0))); assertThat(HashCode.compute((long) 8), is(not(0))); assertThat(HashCode.compute((short) 3), is(not(0))); assertThat(HashCode.compute(1.0f), is(not(0))); assertThat(HashCode.compute(1.0d), is(not(0))); assertThat(HashCode.compute(true), is(not(0))); }
@Test public void testPrimitiveClasses() throws ClassNotFoundException { StatefulSerializer<Serializable> s = new CompactJavaSerializer<>(null); s.init(new TransientStateRepository()); Class<?>[] out = (Class<?>[]) s.read(s.serialize(PRIMITIVE_CLASSES)); Assert.assertThat(out, IsNot.not(IsSame.sameInstance(PRIMITIVE_CLASSES))); Assert.assertThat(out, IsEqual.equalTo(PRIMITIVE_CLASSES)); }
@Test public void equalsOnlyReturnsTrueForEquivalentObjects() { // Arrange: final GroupElement g1 = MathUtils.getRandomGroupElement(); final GroupElement g2 = MathUtils.toRepresentation(g1, GroupElement.Representation.P2); final GroupElement g3 = MathUtils.toRepresentation(g1, GroupElement.Representation.CACHED); final GroupElement g4 = MathUtils.toRepresentation(g1, GroupElement.Representation.P1P1); final GroupElement g5 = MathUtils.getRandomGroupElement(); // Assert Assert.assertThat(g2, IsEqual.equalTo(g1)); Assert.assertThat(g3, IsEqual.equalTo(g1)); Assert.assertThat(g1, IsEqual.equalTo(g4)); Assert.assertThat(g1, IsNot.not(IsEqual.equalTo(g5))); Assert.assertThat(g2, IsNot.not(IsEqual.equalTo(g5))); Assert.assertThat(g3, IsNot.not(IsEqual.equalTo(g5))); Assert.assertThat(g5, IsNot.not(IsEqual.equalTo(g4))); }
@Test public void shouldComputeHashCodeForMultiplePrimitives() { assertThat(HashCode.compute(1, 2, 3), is(not(0))); assertThat(HashCode.compute((long) 8, (long) 22, 33), is(not(0))); assertThat(HashCode.compute((short) 3, (long) 22, true), is(not(0))); }
@Test public void appliesMatcherToXPathInDocument() { assertMatches(hasXPath("/root/something[2]/cheese", equalTo("Cheddar")), xml); assertMatches(hasXPath("//something[1]/cheese", containsString("dam")), xml); assertMatches(hasXPath("//something[2]/cheese", not(containsString("dam"))), xml); assertMatches(hasXPath("/root/@type", equalTo("food")), xml); assertMatches(hasXPath("//something[@id='b']/cheese", equalTo("Cheddar")), xml); assertMatches(hasXPath("//something[@id='b']/cheese"), xml); }
/** * A shortcut to the frequently used <code>not(equalTo(x))</code>. * For example: * <pre>assertThat(cheese, is(not(smelly)))</pre> * instead of: * <pre>assertThat(cheese, is(not(equalTo(smelly))))</pre> * * @param value * the value that any examined object should <b>not</b> equal */ public static <T> Matcher<T> not(T value) { return not(equalTo(value)); } }
@Test public void hashCodesAreEqualForEquivalentObjects() { // Arrange: final FieldElement f1 = getRandomFieldElement(); final FieldElement f2 = getField().getEncoding().decode(f1.toByteArray()); final FieldElement f3 = getRandomFieldElement(); final FieldElement f4 = getRandomFieldElement(); // Assert: Assert.assertThat(f1.hashCode(), IsEqual.equalTo(f2.hashCode())); Assert.assertThat(f1.hashCode(), IsNot.not(IsEqual.equalTo(f3.hashCode()))); Assert.assertThat(f1.hashCode(), IsNot.not(IsEqual.equalTo(f4.hashCode()))); Assert.assertThat(f3.hashCode(), IsNot.not(IsEqual.equalTo(f4.hashCode()))); }
@Test public void testCustomCharSequence() { assertThat(new CustomCharSequence(FOO), IsNot.<CharSequence>not(FOO)); assertThat(FOO, IsNot.<CharSequence>not(new CustomCharSequence(FOO))); assertEquals(new CustomCharSequence(FOO), new CustomCharSequence(FOO)); }
@Test public void liftedFragmentLightCycleAreEqualsWhenTheSourceIsTheSame() { final DefaultFragmentLightCycle<Fragment> lightCycle = new DefaultFragmentLightCycle<>(); final FragmentLightCycle<Fragment> lift1 = LightCycles.lift(lightCycle); final FragmentLightCycle<Fragment> lift2 = LightCycles.lift(lightCycle); assertThat(lift1, not(sameInstance(lift2))); assertThat(lift1, equalTo(lift2)); }
/** * A shortcut to the frequently used <code>not(equalTo(x))</code>. * <p/> * For example: * <pre>assertThat(cheese, is(not(smelly)))</pre> * instead of: * <pre>assertThat(cheese, is(not(equalTo(smelly))))</pre> * * @param value * the value that any examined object should <b>not</b> equal */ @Factory public static <T> Matcher<T> not(T value) { return not(equalTo(value)); } }
@Test public void equalsOnlyReturnsTrueForEquivalentObjects() { // Arrange: final FieldElement f1 = getRandomFieldElement(); final FieldElement f2 = getField().getEncoding().decode(f1.toByteArray()); final FieldElement f3 = getRandomFieldElement(); final FieldElement f4 = getRandomFieldElement(); // Assert: Assert.assertThat(f1, IsEqual.equalTo(f2)); Assert.assertThat(f1, IsNot.not(IsEqual.equalTo(f3))); Assert.assertThat(f1, IsNot.not(IsEqual.equalTo(f4))); Assert.assertThat(f3, IsNot.not(IsEqual.equalTo(f4))); }
@Test public void testSchemaExport() throws Exception { SchemaExport schemaExport = new SchemaExport(); schemaExport.create( EnumSet.of( TargetType.STDOUT, TargetType.DATABASE ), metadata ); List<SQLException> exceptions = schemaExport.getExceptions(); for ( SQLException exception : exceptions ) { assertThat( exception.getMessage(), exception.getSQLState(), not( "42000" ) ); } }
@Test public void droppingAnUnexistingIndexShouldGiveHelpfulExceptionInSeparateTransactions() { // GIVEN IndexDefinition index = createIndex( db, label, propertyKey ); dropIndex( index ); // WHEN try { dropIndex( index ); fail( "Should not be able to drop index twice" ); } catch ( ConstraintViolationException e ) { assertThat( e.getMessage(), containsString( "No such INDEX ON :MY_LABEL(my_property_key)." ) ); } // THEN assertThat( "Index should have been deleted", getIndexes( db, label ), not( contains( index ) ) ); }
@Test public void liftedActivityLightCycleAreEqualsWhenTheSourceIsTheSame() { final DefaultActivityLightCycle<Activity> lightCycle = new DefaultActivityLightCycle<>(); final ActivityLightCycle<Activity> lift1 = LightCycles.lift(lightCycle); final ActivityLightCycle<Activity> lift2 = LightCycles.lift(lightCycle); assertThat(lift1, not(sameInstance(lift2))); assertThat(lift1, equalTo(lift2)); }
/** * A shortcut to the frequently used <code>not(equalTo(x))</code>. * For example: * <pre>assertThat(cheese, is(not(smelly)))</pre> * instead of: * <pre>assertThat(cheese, is(not(equalTo(smelly))))</pre> * * @param value * the value that any examined object should <b>not</b> equal */ public static <T> Matcher<T> not(T value) { return not(equalTo(value)); } }