Пример #1
0
 @Test
 public void fractions() {
   assertEquals(1, QualityValue.valueOf("0.001").intValue());
   assertEquals(12, QualityValue.valueOf("0.012").intValue());
   assertEquals(123, QualityValue.valueOf("0.123").intValue());
   assertEquals(120, QualityValue.valueOf("0.12").intValue());
   assertEquals(100, QualityValue.valueOf("0.1").intValue());
 }
Пример #2
0
 @Test
 public void one() {
   assertEquals(1000, QualityValue.valueOf("1").intValue());
   assertEquals(1000, QualityValue.valueOf("1.").intValue());
   assertEquals(1000, QualityValue.valueOf("1.0").intValue());
   assertEquals(1000, QualityValue.valueOf("1.00").intValue());
   assertEquals(1000, QualityValue.valueOf("1.000").intValue());
 }
Пример #3
0
 @Test
 public void zero() {
   assertEquals(0, QualityValue.valueOf("0").intValue());
   assertEquals(0, QualityValue.valueOf("0.").intValue());
   assertEquals(0, QualityValue.valueOf("0.0").intValue());
   assertEquals(0, QualityValue.valueOf("0.00").intValue());
   assertEquals(0, QualityValue.valueOf("0.000").intValue());
 }
 @Test
 public void simple() {
   String header = "da, en-gb;q=0.8, en;q=0.7";
   Locale[] locales = {new Locale("da"), Locale.UK, Locale.ENGLISH};
   QualityValue[] fields = {
     QualityValue.DEFAULT, QualityValue.valueOf("0.8"), QualityValue.valueOf("0.7"),
   };
   assertList(header, locales, fields);
 }
Пример #5
0
 @Test
 public void numbers() {
   QualityValue x = QualityValue.valueOf("0.08");
   assertEquals(80, x.intValue());
   assertEquals(80L, x.longValue());
   assertEquals(0.08f, x.floatValue(), 0.00001f);
   assertEquals(0.08d, x.doubleValue(), 0.00001d);
 }
Пример #6
0
 @Test
 public void nullContent() {
   assertEquals(QualityValue.DEFAULT, QualityValue.valueOf(null));
 }
Пример #7
0
 @Test(expected = BadRequestException.class)
 public void wrongContent() {
   QualityValue.valueOf("0,2F");
 }
Пример #8
0
 @Test(expected = BadRequestException.class)
 public void tooShort() {
   QualityValue.valueOf("");
 }
Пример #9
0
 @Test(expected = BadRequestException.class)
 public void tooLong() {
   QualityValue.valueOf("0.1234");
 }
Пример #10
0
 @Test(expected = BadRequestException.class)
 public void tooSmall() {
   QualityValue.valueOf("-0.001");
 }
Пример #11
0
 @Test(expected = BadRequestException.class)
 public void tooLarge() {
   QualityValue.valueOf("1.001");
 }
Пример #12
0
 @Test
 public void equivalent() {
   assertTrue(QualityValue.valueOf("0.1").equals(QualityValue.valueOf("0.10")));
   assertFalse(QualityValue.valueOf("1.").equals(QualityValue.valueOf("0.999")));
 }