use of com.spotify.ffwd.v1.Value in project firebase-android-sdk by firebase.
the class RemoteSerializerTest method testEncodesDoubles.
@Test
public void testEncodesDoubles() {
List<Double> tests = asList(Double.NEGATIVE_INFINITY, -Double.MAX_VALUE, Long.MAX_VALUE * -1.0 - 1.0, -2.0, -1.1, -1.0, -Double.MIN_VALUE, -Double.MIN_NORMAL, -0.0, 0.0, Double.MIN_NORMAL, Double.MIN_VALUE, 0.1, 1.1, Long.MAX_VALUE * 1.0, Double.MAX_VALUE, Double.POSITIVE_INFINITY);
for (Double test : tests) {
Value value = wrap(test);
Value proto = Value.newBuilder().setDoubleValue(test).build();
assertRoundTrip(value, proto, Value.ValueTypeCase.DOUBLE_VALUE);
}
}
use of com.spotify.ffwd.v1.Value in project firebase-android-sdk by firebase.
the class RemoteSerializerTest method testEncodesDates.
@Test
public void testEncodesDates() {
Calendar date1 = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
date1.set(2016, 0, 2, 10, 20, 50);
date1.set(Calendar.MILLISECOND, 500);
Calendar date2 = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
date2.set(2016, 5, 17, 10, 50, 15);
date2.set(Calendar.MILLISECOND, 0);
List<Date> tests = asList(date1.getTime(), date2.getTime());
Timestamp ts1 = Timestamp.newBuilder().setNanos(500000000).setSeconds(1451730050).build();
Timestamp ts2 = Timestamp.newBuilder().setNanos(0).setSeconds(1466160615).build();
List<Value> expected = asList(Value.newBuilder().setTimestampValue(ts1).build(), Value.newBuilder().setTimestampValue(ts2).build());
for (int i = 0; i < tests.size(); i++) {
Value value = wrap(tests.get(i));
assertRoundTrip(value, expected.get(i), Value.ValueTypeCase.TIMESTAMP_VALUE);
}
}
use of com.spotify.ffwd.v1.Value in project firebase-android-sdk by firebase.
the class RemoteSerializerTest method testEncodesBlobs.
@Test
public void testEncodesBlobs() {
Value blob = wrap(TestUtil.blob(0, 1, 2, 3));
Value.Builder proto = Value.newBuilder();
proto.setBytesValue(TestUtil.byteString(0, 1, 2, 3));
assertRoundTrip(blob, proto.build(), Value.ValueTypeCase.BYTES_VALUE);
}
use of com.spotify.ffwd.v1.Value in project firebase-android-sdk by firebase.
the class RemoteSerializerTest method testEncodesReferences.
@Test
public void testEncodesReferences() {
DocumentReference value = ref("foo/bar");
Value ref = wrap(value);
Value.Builder proto = Value.newBuilder();
proto.setReferenceValue("projects/project/databases/(default)/documents/foo/bar");
assertRoundTrip(ref, proto.build(), Value.ValueTypeCase.REFERENCE_VALUE);
}
use of com.spotify.ffwd.v1.Value in project firebase-android-sdk by firebase.
the class UserDataWriterTest method testConvertsBlobValue.
@Test
public void testConvertsBlobValue() {
List<Blob> testCases = asList(blob(1, 2, 3), blob(1, 2));
for (Blob b : testCases) {
Value value = wrap(b);
Object convertedValue = convertValue(value);
assertEquals(b, convertedValue);
}
}
Aggregations