// -----------------------------------------------------------------------
  // isBefore, isAfter, isEqual, INSTANT_COMPARATOR  test a Chrono against the other Chronos
  // -----------------------------------------------------------------------
  @Test(
      groups = {"tck"},
      dataProvider = "calendars")
  public void test_zonedDateTime_comparisons(Chrono chrono) {
    List<ChronoZonedDateTime<?>> dates = new ArrayList<>();

    ChronoZonedDateTime<?> date =
        chrono.date(LocalDate.of(1900, 1, 1)).atTime(LocalTime.MIN_TIME).atZone(ZoneOffset.UTC);

    // Insert dates in order, no duplicates
    dates.add(date.minus(100, ChronoUnit.YEARS));
    dates.add(date.minus(1, ChronoUnit.YEARS));
    dates.add(date.minus(1, ChronoUnit.MONTHS));
    dates.add(date.minus(1, ChronoUnit.WEEKS));
    dates.add(date.minus(1, ChronoUnit.DAYS));
    dates.add(date.minus(1, ChronoUnit.HOURS));
    dates.add(date.minus(1, ChronoUnit.MINUTES));
    dates.add(date.minus(1, ChronoUnit.SECONDS));
    dates.add(date.minus(1, ChronoUnit.NANOS));
    dates.add(date);
    dates.add(date.plus(1, ChronoUnit.NANOS));
    dates.add(date.plus(1, ChronoUnit.SECONDS));
    dates.add(date.plus(1, ChronoUnit.MINUTES));
    dates.add(date.plus(1, ChronoUnit.HOURS));
    dates.add(date.plus(1, ChronoUnit.DAYS));
    dates.add(date.plus(1, ChronoUnit.WEEKS));
    dates.add(date.plus(1, ChronoUnit.MONTHS));
    dates.add(date.plus(1, ChronoUnit.YEARS));
    dates.add(date.plus(100, ChronoUnit.YEARS));

    // Check these dates against the corresponding dates for every calendar
    for (Chrono[] clist : data_of_calendars()) {
      List<ChronoZonedDateTime<?>> otherDates = new ArrayList<>();
      Chrono chrono2 = ISOChrono.INSTANCE; // clist[0];
      for (ChronoZonedDateTime<?> d : dates) {
        otherDates.add(chrono2.date(d).atTime(d.getTime()).atZone(d.getZone()));
      }

      // Now compare  the sequence of original dates with the sequence of converted dates
      for (int i = 0; i < dates.size(); i++) {
        ChronoZonedDateTime<?> a = dates.get(i);
        for (int j = 0; j < otherDates.size(); j++) {
          ChronoZonedDateTime<?> b = otherDates.get(j);
          int cmp = ChronoZonedDateTime.INSTANT_COMPARATOR.compare(a, b);
          if (i < j) {
            assertTrue(cmp < 0, a + " compare " + b);
            assertEquals(a.isBefore(b), true, a + " isBefore " + b);
            assertEquals(a.isAfter(b), false, a + " ifAfter " + b);
            assertEquals(a.isEqual(b), false, a + " isEqual " + b);
          } else if (i > j) {
            assertTrue(cmp > 0, a + " compare " + b);
            assertEquals(a.isBefore(b), false, a + " isBefore " + b);
            assertEquals(a.isAfter(b), true, a + " ifAfter " + b);
            assertEquals(a.isEqual(b), false, a + " isEqual " + b);
          } else {
            assertTrue(cmp == 0, a + " compare " + b);
            assertEquals(a.isBefore(b), false, a + " isBefore " + b);
            assertEquals(a.isAfter(b), false, a + " ifAfter " + b);
            assertEquals(a.isEqual(b), true, a + " isEqual " + b);
          }
        }
      }
    }
  }
 @Test(
     groups = {"tck"},
     dataProvider = "calendars")
 public void test_badWithAdjusterChrono(Chrono<?> chrono) {
   LocalDate refDate = LocalDate.of(1900, 1, 1);
   ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.MIDDAY).atZone(ZoneOffset.UTC);
   for (Chrono[] clist : data_of_calendars()) {
     Chrono chrono2 = clist[0];
     ChronoZonedDateTime<?> czdt2 =
         chrono2.date(refDate).atTime(LocalTime.MIDDAY).atZone(ZoneOffset.UTC);
     DateTime.WithAdjuster adjuster = new FixedAdjuster(czdt2);
     if (chrono != chrono2) {
       try {
         czdt.with(adjuster);
         Assert.fail(
             "WithAdjuster should have thrown a ClassCastException, "
                 + "required: "
                 + czdt
                 + ", supplied: "
                 + czdt2);
       } catch (ClassCastException cce) {
         // Expected exception; not an error
       }
     } else {
       ChronoZonedDateTime<?> result = czdt.with(adjuster);
       assertEquals(result, czdt2, "WithAdjuster failed to replace date");
     }
   }
 }
 @Test(
     groups = {"tck"},
     dataProvider = "calendars")
 public void test_badDateTimeFieldChrono(Chrono chrono) {
   LocalDate refDate = LocalDate.of(1900, 1, 1);
   ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.MIDDAY).atZone(ZoneOffset.UTC);
   for (Chrono[] clist : data_of_calendars()) {
     Chrono chrono2 = clist[0];
     ChronoZonedDateTime<?> czdt2 =
         chrono2.date(refDate).atTime(LocalTime.MIDDAY).atZone(ZoneOffset.UTC);
     DateTimeField adjuster = new FixedDateTimeField(czdt2);
     if (chrono != chrono2) {
       try {
         ChronoZonedDateTime<?> notreached = czdt.with(adjuster, 1);
         Assert.fail(
             "DateTimeField doWith() should have thrown a ClassCastException, "
                 + czdt.getClass()
                 + " can not be cast to "
                 + czdt2.getClass());
       } catch (ClassCastException cce) {
         // Expected exception; not an error
       }
     } else {
       // Same chronology,
       ChronoZonedDateTime<?> result = czdt.with(adjuster, 1);
       assertEquals(result, czdt2, "DateTimeField doWith() failed to replace date");
     }
   }
 }