Search in sources :

Example 1 with OCaseInsensitiveCollate

use of com.orientechnologies.orient.core.collate.OCaseInsensitiveCollate in project orientdb by orientechnologies.

the class BinaryComparatorCompareTest method testString.

@Test
public void testString() {
    Assert.assertEquals(comparator.compare(field(OType.STRING, "test"), field(OType.STRING, "test")), 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "test2"), field(OType.STRING, "test")) > 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "test"), field(OType.STRING, "test2")) < 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "t"), field(OType.STRING, "te")) < 0);
    // DEF COLLATE
    Assert.assertEquals(comparator.compare(field(OType.STRING, "test", new ODefaultCollate()), field(OType.STRING, "test")), 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "test2", new ODefaultCollate()), field(OType.STRING, "test")) > 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "test", new ODefaultCollate()), field(OType.STRING, "test2")) < 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "t", new ODefaultCollate()), field(OType.STRING, "te")) < 0);
    Assert.assertEquals(comparator.compare(field(OType.STRING, "test", new ODefaultCollate()), field(OType.STRING, "test", new ODefaultCollate())), 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "test2", new ODefaultCollate()), field(OType.STRING, "test", new ODefaultCollate())) > 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "test", new ODefaultCollate()), field(OType.STRING, "test2", new ODefaultCollate())) < 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "t", new ODefaultCollate()), field(OType.STRING, "te", new ODefaultCollate())) < 0);
    Assert.assertEquals(comparator.compare(field(OType.STRING, "test"), field(OType.STRING, "test", new ODefaultCollate())), 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "test2"), field(OType.STRING, "test", new ODefaultCollate())) > 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "test"), field(OType.STRING, "test2", new ODefaultCollate())) < 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "t"), field(OType.STRING, "te", new ODefaultCollate())) < 0);
    // CASE INSENSITIVE COLLATE
    Assert.assertEquals(comparator.compare(field(OType.STRING, "test"), field(OType.STRING, "test", new OCaseInsensitiveCollate())), 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "test2"), field(OType.STRING, "test", new OCaseInsensitiveCollate())) > 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "test"), field(OType.STRING, "test2", new OCaseInsensitiveCollate())) < 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "t"), field(OType.STRING, "te", new OCaseInsensitiveCollate())) < 0);
    Assert.assertEquals(comparator.compare(field(OType.STRING, "test"), field(OType.STRING, "TEST", new OCaseInsensitiveCollate())), 0);
    Assert.assertEquals(comparator.compare(field(OType.STRING, "TEST"), field(OType.STRING, "TEST", new OCaseInsensitiveCollate())), 0);
    Assert.assertEquals(comparator.compare(field(OType.STRING, "TE"), field(OType.STRING, "te", new OCaseInsensitiveCollate())), 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "test2"), field(OType.STRING, "TEST", new OCaseInsensitiveCollate())) > 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "test"), field(OType.STRING, "TEST2", new OCaseInsensitiveCollate())) < 0);
    Assert.assertTrue(comparator.compare(field(OType.STRING, "t"), field(OType.STRING, "tE", new OCaseInsensitiveCollate())) < 0);
}
Also used : OCaseInsensitiveCollate(com.orientechnologies.orient.core.collate.OCaseInsensitiveCollate) ODefaultCollate(com.orientechnologies.orient.core.collate.ODefaultCollate) Test(org.testng.annotations.Test)

Example 2 with OCaseInsensitiveCollate

use of com.orientechnologies.orient.core.collate.OCaseInsensitiveCollate in project orientdb by orientechnologies.

the class BinaryComparatorEqualsTest method testBinaryFieldCopy.

@Test
public void testBinaryFieldCopy() {
    final OBinaryField f = field(OType.BYTE, 10, new OCaseInsensitiveCollate()).copy();
    Assert.assertEquals(f.type, OType.BYTE);
    Assert.assertNotNull(f.bytes);
    Assert.assertEquals(f.collate.getName(), OCaseInsensitiveCollate.NAME);
}
Also used : OCaseInsensitiveCollate(com.orientechnologies.orient.core.collate.OCaseInsensitiveCollate) OBinaryField(com.orientechnologies.orient.core.serialization.serializer.record.binary.OBinaryField) Test(org.testng.annotations.Test)

Example 3 with OCaseInsensitiveCollate

use of com.orientechnologies.orient.core.collate.OCaseInsensitiveCollate in project orientdb by orientechnologies.

the class BinaryComparatorEqualsTest method testString.

@Test
public void testString() {
    Assert.assertTrue(comparator.isEqual(field(OType.STRING, "test"), field(OType.STRING, "test")));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "test2"), field(OType.STRING, "test")));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "test"), field(OType.STRING, "test2")));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "t"), field(OType.STRING, "te")));
    // DEF COLLATE
    Assert.assertTrue(comparator.isEqual(field(OType.STRING, "test", new ODefaultCollate()), field(OType.STRING, "test")));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "test2", new ODefaultCollate()), field(OType.STRING, "test")));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "test", new ODefaultCollate()), field(OType.STRING, "test2")));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "t", new ODefaultCollate()), field(OType.STRING, "te")));
    Assert.assertTrue(comparator.isEqual(field(OType.STRING, "test", new ODefaultCollate()), field(OType.STRING, "test", new ODefaultCollate())));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "test2", new ODefaultCollate()), field(OType.STRING, "test", new ODefaultCollate())));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "test", new ODefaultCollate()), field(OType.STRING, "test2", new ODefaultCollate())));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "t", new ODefaultCollate()), field(OType.STRING, "te", new ODefaultCollate())));
    Assert.assertTrue(comparator.isEqual(field(OType.STRING, "test"), field(OType.STRING, "test", new ODefaultCollate())));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "test2"), field(OType.STRING, "test", new ODefaultCollate())));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "test"), field(OType.STRING, "test2", new ODefaultCollate())));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "t"), field(OType.STRING, "te", new ODefaultCollate())));
    // CASE INSENSITIVE COLLATE
    Assert.assertTrue(comparator.isEqual(field(OType.STRING, "test"), field(OType.STRING, "test", new OCaseInsensitiveCollate())));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "test2"), field(OType.STRING, "test", new OCaseInsensitiveCollate())));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "test"), field(OType.STRING, "test2", new OCaseInsensitiveCollate())));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "t"), field(OType.STRING, "te", new OCaseInsensitiveCollate())));
    Assert.assertTrue(comparator.isEqual(field(OType.STRING, "test"), field(OType.STRING, "TEST", new OCaseInsensitiveCollate())));
    Assert.assertTrue(comparator.isEqual(field(OType.STRING, "TEST"), field(OType.STRING, "TEST", new OCaseInsensitiveCollate())));
    Assert.assertTrue(comparator.isEqual(field(OType.STRING, "TE"), field(OType.STRING, "te", new OCaseInsensitiveCollate())));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "test2"), field(OType.STRING, "TEST", new OCaseInsensitiveCollate())));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "test"), field(OType.STRING, "TEST2", new OCaseInsensitiveCollate())));
    Assert.assertFalse(comparator.isEqual(field(OType.STRING, "t"), field(OType.STRING, "tE", new OCaseInsensitiveCollate())));
}
Also used : OCaseInsensitiveCollate(com.orientechnologies.orient.core.collate.OCaseInsensitiveCollate) ODefaultCollate(com.orientechnologies.orient.core.collate.ODefaultCollate) Test(org.testng.annotations.Test)

Aggregations

OCaseInsensitiveCollate (com.orientechnologies.orient.core.collate.OCaseInsensitiveCollate)3 Test (org.testng.annotations.Test)3 ODefaultCollate (com.orientechnologies.orient.core.collate.ODefaultCollate)2 OBinaryField (com.orientechnologies.orient.core.serialization.serializer.record.binary.OBinaryField)1