   @Test
    public void testFindSampleLessOrEqual() throws Exception
    {

        double x;
        int i;

        // Exact find
        x = 4.0;
        i = ChartSampleSearch.findSampleLessOrEqual(samples, x);
        //System.out.println("Looking for " + x + ", found " + samples.get(i).getX());
        assertTrue(i >= 0);
        assertTrue(i < samples.size());
        assertTrue(samples.get(i).getX() == x);

        // Samples contain 4 and 6, but not 5
        x = 5.0;
        i = ChartSampleSearch.findSampleLessOrEqual(samples, x);
        //System.out.println("Looking for " + x + ", found " + samples.get(i).getX());
        assertTrue(i >= 0);
        assertTrue(i < samples.size());
        assertTrue(samples.get(i).getX() < x);

        // Lower end
        x = 2.0;
        i = ChartSampleSearch.findSampleLessOrEqual(samples, x);
        //System.out.println("Looking for " + x + ", found " + samples.get(i).getX());
        assertTrue(i >= 0);
        assertTrue(i < samples.size());
        assertTrue(samples.get(i).getX() == x);

        // Upper end
        x = 18.0;
        i = ChartSampleSearch.findSampleLessOrEqual(samples, x);
        //System.out.println("Looking for " + x + ", found " + samples.get(i).getX());
        assertTrue(i >= 0);
        assertTrue(i < samples.size());
        assertTrue(samples.get(i).getX() == x);

        // Below lower end
        x = 1.0;
        i = ChartSampleSearch.findSampleLessOrEqual(samples, x);
        assertEquals(-1, i);
        //System.out.println("Looking for " + x + ", found nothing");

        // Beyond upper end
        x = 20.0;
        i = ChartSampleSearch.findSampleLessOrEqual(samples, x);
        //System.out.println("Looking for " + x + ", found " + samples.get(i).getX());
        assertTrue(i >= 0);
        assertTrue(i < samples.size());
        assertTrue(samples.get(i).getX() < x);
   }