コード例 #1
0
 @Test(dataProvider = "Pad")
 public void test_pad_NEVER(int minPad, int maxPad, long value, String result) throws Exception {
   printContext.setCalendrical(new MockFieldValue(DAY_OF_MONTH, value));
   NumberPrinterParser pp = new NumberPrinterParser(DAY_OF_MONTH, minPad, maxPad, SignStyle.NEVER);
   try {
     pp.print(printContext, buf);
     if (result == null) {
       fail("Expected exception");
     }
     assertEquals(buf.toString(), result);
   } catch (DateTimePrintException ex) {
     if (result != null) {
       throw ex;
     }
     assertEquals(ex.getMessage().contains(DAY_OF_MONTH.getName()), true);
   }
 }
コード例 #2
0
 @Test(dataProvider = "Pad")
 public void test_pad_EXCEEDS_PAD(int minPad, int maxPad, long value, String result)
     throws Exception {
   printContext.setCalendrical(new MockFieldValue(DAY_OF_MONTH, value));
   NumberPrinterParser pp =
       new NumberPrinterParser(DAY_OF_MONTH, minPad, maxPad, SignStyle.EXCEEDS_PAD);
   try {
     pp.print(printContext, buf);
     if (result == null) {
       fail("Expected exception");
       return; // unreachable
     }
     if (result.length() > minPad || value < 0) {
       result = (value < 0 ? "-" + result : "+" + result);
     }
     assertEquals(buf.toString(), result);
   } catch (DateTimePrintException ex) {
     if (result != null) {
       throw ex;
     }
     assertEquals(ex.getMessage().contains(DAY_OF_MONTH.getName()), true);
   }
 }