package ch.pollet.jzic.timezone;
import ch.pollet.jzic.timezone.Period;
import ch.pollet.jzic.datetime.DateTime;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author Christophe Pollet
*/
public class PeriodTest {
@Test
public void testSameAs() {
Period p1 = new Period();
Period p2 = new Period();
p1.setOffset(1);
p1.setPeriodName("foo");
p2.setOffset(1);
p2.setPeriodName("foo");
assertTrue(p1.sameAs(p2));
assertTrue(p2.sameAs(p1));
p2.setOffset(2);
assertFalse(p1.sameAs(p2));
assertFalse(p2.sameAs(p1));
p2.setOffset(1);
p2.setPeriodName("bar");
assertFalse(p1.sameAs(p2));
assertFalse(p2.sameAs(p1));
p2.setPeriodName("foo");
p2.isStdOffset(true);
assertFalse(p1.sameAs(p2));
assertFalse(p2.sameAs(p1));
}
@Test
public void testCompareTo() {
}
@Test
public void testClone() {
Period p1 = new Period();
Period p2;
DateTime from = new DateTime();
DateTime to = new DateTime();
from.setYear(2000);
from.setMonth(6);
from.setDay(1);
from.setHour(0);
from.setMinute(0);
from.setSecond(0);
from.setType(DateTime.Type.UTC);
to.setYear(2000);
to.setMonth(7);
to.setDay(1);
to.setHour(0);
to.setMinute(0);
to.setSecond(0);
to.setType(DateTime.Type.UTC);
p1.setFormat("format");
p1.setFrom(from);
p1.setOffset(1);
p1.setPeriodName("periodName");
p1.setTo(to);
p1.isStdOffset(false);
p2 = p1.clone();
assertEquals(p1.getFormat(), p2.getFormat());
assertEquals(p1.getFrom(), p2.getFrom());
assertEquals(p1.getOffset(), p2.getOffset());
assertEquals(p1.getPeriodName(), p2.getPeriodName());
assertEquals(p1.getTo(), p2.getTo());
assertEquals(p1.isStdOffset(), p2.isStdOffset());
assertFalse(p1 == p2);
assertFalse(p1.getFrom() == p2.getFrom());
assertFalse(p1.getTo() == p2.getTo());
}
}