// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/DateTimeIndexFieldDefinition.java
// public enum Precision {DATETIME, DATETIME_NOMILLIS, DATE, TIME, TIME_NOMILLIS}


import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Test;
import org.lilycms.hbaseindex.*;
import org.lilycms.hbaseindex.DateTimeIndexFieldDefinition.Precision;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.GregorianCalendar;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
                    }
                }
            }
        }

        // Verify cutoff of precision
        DecimalIndexFieldDefinition fieldDef = new DecimalIndexFieldDefinition("foobar");
        fieldDef.setLength(5);
        byte[] r1 = fieldDef.toBytes(new BigDecimal("10.000000000000000000000000000000000000000000000000000000000000001"));
        byte[] r2 = fieldDef.toBytes(new BigDecimal("10.000000000000000000000000000000000000000000000000000000000000002"));

        assertEquals(5, r1.length);
        assertEquals(5, r2.length);

        assertEquals(0, Bytes.compareTo(r1, r2));

        // Verify checks on maximum supported exponents
        try {
            toSortableBytes(new BigDecimal("0.1E16384"));
            fail("Expected error");
        } catch (RuntimeException e) {}

        try {
            toSortableBytes(new BigDecimal("0.1E-16385"));
            fail("Expected error");
        } catch (RuntimeException e) {}
    }

    @Test
    public void testDateCompare() throws Exception {
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/DateTimeIndexFieldDefinition.java
// public enum Precision {DATETIME, DATETIME_NOMILLIS, DATE, TIME, TIME_NOMILLIS}


// Path: src/hbaseindex/src/test/java/org/lilycms/hbaseindex/test/ByteComparisonTest.java
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Test;
import org.lilycms.hbaseindex.*;
import org.lilycms.hbaseindex.DateTimeIndexFieldDefinition.Precision;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.GregorianCalendar;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

                    }
                }
            }
        }

        // Verify cutoff of precision
        DecimalIndexFieldDefinition fieldDef = new DecimalIndexFieldDefinition("foobar");
        fieldDef.setLength(5);
        byte[] r1 = fieldDef.toBytes(new BigDecimal("10.000000000000000000000000000000000000000000000000000000000000001"));
        byte[] r2 = fieldDef.toBytes(new BigDecimal("10.000000000000000000000000000000000000000000000000000000000000002"));

        assertEquals(5, r1.length);
        assertEquals(5, r2.length);

        assertEquals(0, Bytes.compareTo(r1, r2));

        // Verify checks on maximum supported exponents
        try {
            toSortableBytes(new BigDecimal("0.1E16384"));
            fail("Expected error");
        } catch (RuntimeException e) {}

        try {
            toSortableBytes(new BigDecimal("0.1E-16385"));
            fail("Expected error");
        } catch (RuntimeException e) {}
    }

    @Test
    public void testDateCompare() throws Exception {
        byte[] bytes1 = date(Precision.DATE, 2010, 2, 1, 14, 20, 10, 333);