use of io.realm.entities.IOSAllTypes in project realm-java by realm.
the class IOSRealmTests method iOSDataTypesNullValues.
@Test
public void iOSDataTypesNullValues() throws IOException {
for (String iosVersion : IOS_VERSIONS) {
configFactory.copyRealmFromAssets(context, "ios/" + iosVersion + "-alltypes-null-value.realm", REALM_NAME);
realm = Realm.getDefaultInstance();
IOSAllTypes obj = realm.where(IOSAllTypes.class).findFirst();
assertEquals(null, obj.getByteCol());
assertEquals(null, obj.getStringCol());
assertEquals(null, obj.getDateCol());
assertEquals(null, obj.getChild());
assertEquals(new RealmList<IOSChild>(), obj.getChildren());
}
}
use of io.realm.entities.IOSAllTypes in project realm-java by realm.
the class IOSRealmTests method iOSDataTypesMaximumValues.
@Test
public void iOSDataTypesMaximumValues() throws IOException {
for (String iosVersion : IOS_VERSIONS) {
configFactory.copyRealmFromAssets(context, "ios/" + iosVersion + "-alltypes-max.realm", REALM_NAME);
realm = Realm.getDefaultInstance();
IOSAllTypes obj = realm.where(IOSAllTypes.class).findFirst();
assertEquals(Short.MAX_VALUE, obj.getShortCol());
assertEquals(Integer.MAX_VALUE, obj.getIntCol());
assertEquals(Integer.MAX_VALUE, obj.getLongCol());
assertEquals(Long.MAX_VALUE, obj.getLongLongCol());
assertEquals(Float.MAX_VALUE, obj.getFloatCol(), 0F);
assertEquals(Double.MAX_VALUE, obj.getDoubleCol(), 0D);
assertArrayEquals(new byte[0], obj.getByteCol());
assertEquals("", obj.getStringCol());
assertEquals(0x8000000000000000L * 1000L, obj.getDateCol().getTime());
}
}
use of io.realm.entities.IOSAllTypes in project realm-java by realm.
the class IOSRealmTests method iOSDataTypesMinimumValues.
@Test
public void iOSDataTypesMinimumValues() throws IOException {
for (String iosVersion : IOS_VERSIONS) {
configFactory.copyRealmFromAssets(context, "ios/" + iosVersion + "-alltypes-min.realm", REALM_NAME);
realm = Realm.getDefaultInstance();
IOSAllTypes obj = realm.where(IOSAllTypes.class).findFirst();
assertFalse(obj.isBoolCol());
assertEquals(Short.MIN_VALUE, obj.getShortCol());
assertEquals(Integer.MIN_VALUE, obj.getIntCol());
assertEquals(Integer.MIN_VALUE, obj.getLongCol());
assertEquals(Long.MIN_VALUE, obj.getLongLongCol());
assertEquals(-Float.MAX_VALUE, obj.getFloatCol(), 0F);
assertEquals(-Double.MAX_VALUE, obj.getDoubleCol(), 0D);
assertArrayEquals(new byte[0], obj.getByteCol());
assertEquals("", obj.getStringCol());
assertEquals(0x8000000000000000L * 1000L, obj.getDateCol().getTime());
}
}
use of io.realm.entities.IOSAllTypes in project realm-java by realm.
the class IOSRealmTests method iOSDataTypesDefaultValues.
@Test
public void iOSDataTypesDefaultValues() throws IOException {
for (String iosVersion : IOS_VERSIONS) {
configFactory.copyRealmFromAssets(context, "ios/" + iosVersion + "-alltypes-default.realm", REALM_NAME);
realm = Realm.getDefaultInstance();
IOSAllTypes obj = realm.where(IOSAllTypes.class).findFirst();
assertFalse(obj.isBoolCol());
assertEquals(0, obj.getShortCol());
assertEquals(0, obj.getIntCol());
assertEquals(0, obj.getLongCol());
assertEquals(0L, obj.getLongLongCol());
assertEquals(0.0F, obj.getFloatCol(), 0F);
assertEquals(0.0D, obj.getDoubleCol(), 0D);
assertArrayEquals(new byte[0], obj.getByteCol());
assertEquals("", obj.getStringCol());
assertEquals(new Date(0), obj.getDateCol());
assertNull(obj.getChild());
assertEquals(0, obj.getChildren().size());
}
}
use of io.realm.entities.IOSAllTypes in project realm-java by realm.
the class IOSRealmTests method iOSDataTypes.
@Test
public void iOSDataTypes() throws IOException {
for (String iosVersion : IOS_VERSIONS) {
configFactory.copyRealmFromAssets(context, "ios/" + iosVersion + "-alltypes.realm", REALM_NAME);
realm = Realm.getDefaultInstance();
RealmResults<IOSAllTypes> result = realm.where(IOSAllTypes.class).findAllSorted("id", Sort.ASCENDING);
// Verifies metadata.
Table table = realm.getTable(IOSAllTypes.class);
assertTrue(table.hasPrimaryKey());
assertTrue(table.hasSearchIndex(table.getColumnIndex("id")));
// Iterative check.
for (int i = 0; i < 10; i++) {
IOSAllTypes obj = result.get(i);
assertTrue(obj.isBoolCol());
assertEquals(i + 1, obj.getShortCol());
assertEquals(10 + i, obj.getIntCol());
assertEquals(100 + i, obj.getLongCol());
assertEquals(100000000L + (long) i, obj.getLongLongCol());
assertEquals(1.23F + (float) i, obj.getFloatCol(), 0F);
assertEquals(1.234D + (double) i, obj.getDoubleCol(), 0D);
assertArrayEquals(new byte[] { 1, 2, 3 }, obj.getByteCol());
assertEquals("String " + Integer.toString(i), obj.getStringCol());
assertEquals(new Date((1000 + i) * 1000), obj.getDateCol());
assertEquals("Foo", result.get(i).getChild().getName());
assertEquals(10, result.get(i).getChildren().size());
for (int j = 0; j < 10; j++) {
assertEquals("Name: " + Integer.toString(i), result.get(i).getChildren().get(j).getName());
}
}
}
}
Aggregations