Java Code Examples for com.google.cloud.datastore.DoubleValue#of()

The following examples show how to use com.google.cloud.datastore.DoubleValue#of() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FloatMapperTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test
public void testToModel_1() {
  double d = 0.000000;
  DoubleValue input = DoubleValue.of(d);
  FloatMapper mapper = new FloatMapper();
  float output = (float) mapper.toModel(input);
  System.out.printf("%s ---> %s%n", d, output);
  assertTrue(0.000000f == output);
}
 
Example 2
Source File: FloatMapperTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test
public void testToModel_2() {
  double d = 3.1415927;
  DoubleValue input = DoubleValue.of(d);
  FloatMapper mapper = new FloatMapper();
  float output = (float) mapper.toModel(input);
  System.out.printf("%s ---> %s%n", d, output);
  assertTrue(3.1415927f == output);
}
 
Example 3
Source File: FloatMapperTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test
public void testToModel_3() {
  double d = Float.MAX_VALUE;
  DoubleValue input = DoubleValue.of(d);
  FloatMapper mapper = new FloatMapper();
  float output = (float) mapper.toModel(input);
  System.out.printf("%s ---> %s%n", d, output);
  assertTrue(Float.MAX_VALUE == output);
}
 
Example 4
Source File: FloatMapperTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test
public void testToModel_4() {
  double d = -Float.MAX_VALUE;
  DoubleValue input = DoubleValue.of(d);
  FloatMapper mapper = new FloatMapper();
  float output = (float) mapper.toModel(input);
  System.out.printf("%s ---> %s%n", d, output);
  assertTrue(-Float.MAX_VALUE == output);
}
 
Example 5
Source File: FloatMapperTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test(expected = MappingException.class)
public void testToModel_5() {
  double d = Float.MAX_VALUE * 2d;
  DoubleValue input = DoubleValue.of(d);
  FloatMapper mapper = new FloatMapper();
  try {
    float output = (float) mapper.toModel(input);
  } catch (Exception e) {
    System.err.println(e);
    throw e;
  }
}
 
Example 6
Source File: FloatMapperTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test(expected = MappingException.class)
public void testToModel_6() {
  double d = -Float.MAX_VALUE * 2d;
  DoubleValue input = DoubleValue.of(d);
  FloatMapper mapper = new FloatMapper();
  try {
    float output = (float) mapper.toModel(input);
  } catch (Exception e) {
    System.err.println(e);
    throw e;
  }
}
 
Example 7
Source File: FloatMapperTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test
public void testToModel_7() {
  double d = 1.0000;
  DoubleValue input = DoubleValue.of(d);
  FloatMapper mapper = new FloatMapper();
  float output = (float) mapper.toModel(input);
  System.out.printf("%s ---> %s%n", d, output);
  assertTrue(1.0000f == output);
}
 
Example 8
Source File: FloatMapperTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test
public void testToModel_8() {
  double d = 999.9999;
  DoubleValue input = DoubleValue.of(d);
  FloatMapper mapper = new FloatMapper();
  float output = (float) mapper.toModel(input);
  System.out.printf("%s ---> %s%n", d, output);
  assertTrue(999.9999f == output);
}