/*
* Copyright 2009 Peter Karich, peat_hal 'at' users 'dot' sourceforge 'dot' net.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* under the License.
*/
package de.timefinder.data.set;
import de.timefinder.data.set.DayRaster;
import de.timefinder.data.set.Raster;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* @author Peter Karich, peat_hal 'at' users 'dot' sourceforge 'dot' net
*/
public class DayRasterTest {
private int DAYS = 2;
private int SLOTS = 5;
private Raster raster;
public DayRasterTest() {
}
@Before
public void setUp() {
raster = new DayRaster(SLOTS, SLOTS * DAYS);
}
@Test
public void testGetNextFree() {
assertEquals(0, raster.getNextFree(0, 5));
assertEquals(5, raster.getNextFree(1, 5));
assertEquals(1, raster.getNextFree(1, 3));
assertEquals(-1, raster.getNextFree(10, 1));
assertEquals(-1, raster.getNextFree(0, 6));
}
@Test
public void testGetLastFreePlus1() {
int until = SLOTS;
assertEquals(until, raster.getLastFreePlus1(0));
assertEquals(until, raster.getLastFreePlus1(1));
assertEquals(until, raster.getLastFreePlus1(2));
assertEquals(until, raster.getLastFreePlus1(3));
assertEquals(until, raster.getLastFreePlus1(4));
until = 2 * SLOTS;
assertEquals(until, raster.getLastFreePlus1(5));
assertEquals(until, raster.getLastFreePlus1(6));
assertEquals(until, raster.getLastFreePlus1(7));
assertEquals(until, raster.getLastFreePlus1(8));
assertEquals(until, raster.getLastFreePlus1(9));
assertEquals(-1, raster.getLastFreePlus1(10));
assertEquals(-1, raster.getLastFreePlus1(11));
}
}