コード例 #1
0
 @Test
 public void testHashCode() {
   List<AmountFormatContext> contexts = new ArrayList<AmountFormatContext>();
   contexts.add(AmountFormatContextBuilder.of(Locale.GERMAN).build());
   contexts.add(AmountFormatContextBuilder.of(Locale.ENGLISH).build());
   Set<Integer> hashCodes = new HashSet<Integer>();
   for (AmountFormatContext amountFormatContext : contexts) {
     hashCodes.add(amountFormatContext.hashCode());
   }
   // Check we have 5 distinct hash codes...
   assertTrue(hashCodes.size() == 2);
 }
コード例 #2
0
 @Test
 public void testToString() throws Exception {
   AmountFormatContext style =
       AmountFormatContextBuilder.of(Locale.GERMAN)
           .set("groupSizes", new int[] {1, 2, 3, 4})
           .set("currencyStyle", "NUMERIC_CODE")
           .set("pattern", "###")
           .build();
   String toString = style.toString();
   assertNotNull(toString);
   assertTrue(toString.contains("DE"));
   assertTrue(toString.contains("java.util.Locale"));
   assertTrue(toString.contains("groupSizes"));
   assertTrue(toString.contains("###"));
   assertTrue(toString.contains("NUMERIC_CODE"));
   assertTrue(toString.contains("currencyStyle"));
   assertTrue(toString.contains("AmountFormatContext"));
 }