Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void compareToSameAsValue()
        public virtual void CompareToSameAsValue()
        {
            Value[] values = new Value[] { DateTimeValue.datetime(9999, 100, ZoneId.of("+18:00")), DateTimeValue.datetime(10000, 100, ZoneId.of("-18:00")), DateTimeValue.datetime(10000, 100, ZoneOffset.of("-17:59:59")), DateTimeValue.datetime(10000, 100, ZoneId.of("UTC")), DateTimeValue.datetime(10000, 100, ZoneId.of("+01:00")), DateTimeValue.datetime(10000, 100, ZoneId.of("Europe/Stockholm")), DateTimeValue.datetime(10000, 100, ZoneId.of("+03:00")), DateTimeValue.datetime(10000, 101, ZoneId.of("-18:00")) };

            ZonedDateTimeIndexKey keyI = new ZonedDateTimeIndexKey();
            ZonedDateTimeIndexKey keyJ = new ZonedDateTimeIndexKey();

            int len = values.Length;

            for (int i = 0; i < len; i++)
            {
                for (int j = 0; j < len; j++)
                {
                    Value vi = values[i];
                    Value vj = values[j];
                    vi.WriteTo(keyI);
                    vj.WriteTo(keyJ);

                    int expected = Integer.signum(Values.COMPARATOR.Compare(vi, vj));
                    assertEquals(format("comparing %s and %s", vi, vj), expected, Integer.signum(i - j));
                    assertEquals(format("comparing %s and %s", vi, vj), expected, Integer.signum(keyI.CompareValueTo(keyJ)));
                }
            }
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadAndWriteConsistentValues()
        public virtual void ShouldReadAndWriteConsistentValues()
        {
            Value[] values = new Value[] { DateTimeValue.datetime(9999, 100, ZoneId.of("+18:00")), DateTimeValue.datetime(10000, 100, ZoneId.of("-18:00")), DateTimeValue.datetime(10000, 100, ZoneOffset.of("-17:59:59")), DateTimeValue.datetime(10000, 100, ZoneId.of("UTC")), DateTimeValue.datetime(10000, 100, ZoneId.of("+01:00")), DateTimeValue.datetime(10000, 100, ZoneId.of("Europe/Stockholm")), DateTimeValue.datetime(10000, 100, ZoneId.of("+03:00")), DateTimeValue.datetime(10000, 101, ZoneId.of("-18:00")) };

            ZonedDateTimeLayout   layout   = new ZonedDateTimeLayout();
            PageCursor            cursor   = new StubPageCursor(0, 8 * 1024);
            ZonedDateTimeIndexKey writeKey = layout.NewKey();
            ZonedDateTimeIndexKey readKey  = layout.NewKey();

            // Write all
            foreach (Value value in values)
            {
                value.WriteTo(writeKey);
                layout.WriteKey(cursor, writeKey);
            }

            // Read all
            cursor.Offset = 0;
            foreach (Value value in values)
            {
                layout.ReadKey(cursor, readKey, ZonedDateTimeIndexKey.Size);
                assertEquals(value, readKey.AsValue());
            }
        }