Search in sources :

Example 1 with ODefaultCollate

use of com.orientechnologies.orient.core.collate.ODefaultCollate 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 ODefaultCollate

use of com.orientechnologies.orient.core.collate.ODefaultCollate 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)2 ODefaultCollate (com.orientechnologies.orient.core.collate.ODefaultCollate)2 Test (org.testng.annotations.Test)2