use of org.joda.time.TimeOfDay in project joda-time by JodaOrg.
the class TestPreciseDateTimeField method test_add_RP_int_intarray_int.
public void test_add_RP_int_intarray_int() {
int[] values = new int[] { 10, 20, 30, 40 };
int[] expected = new int[] { 10, 20, 30, 40 };
BaseDateTimeField field = new MockStandardDateTimeField();
int[] result = field.add(new TimeOfDay(), 2, values, 0);
assertEquals(true, Arrays.equals(expected, result));
values = new int[] { 10, 20, 30, 40 };
expected = new int[] { 10, 20, 31, 40 };
result = field.add(new TimeOfDay(), 2, values, 1);
assertEquals(true, Arrays.equals(expected, result));
values = new int[] { 10, 20, 30, 40 };
expected = new int[] { 10, 21, 0, 40 };
result = field.add(new TimeOfDay(), 2, values, 30);
assertEquals(true, Arrays.equals(expected, result));
values = new int[] { 23, 59, 30, 40 };
try {
field.add(new TimeOfDay(), 2, values, 30);
fail();
} catch (IllegalArgumentException ex) {
}
values = new int[] { 10, 20, 30, 40 };
expected = new int[] { 10, 20, 29, 40 };
result = field.add(new TimeOfDay(), 2, values, -1);
assertEquals(true, Arrays.equals(expected, result));
values = new int[] { 10, 20, 30, 40 };
expected = new int[] { 10, 19, 59, 40 };
result = field.add(new TimeOfDay(), 2, values, -31);
assertEquals(true, Arrays.equals(expected, result));
values = new int[] { 0, 0, 30, 40 };
try {
field.add(new TimeOfDay(), 2, values, -31);
fail();
} catch (IllegalArgumentException ex) {
}
}
use of org.joda.time.TimeOfDay in project joda-time by JodaOrg.
the class TestPreciseDateTimeField method test_set_RP_int_intarray_String_Locale.
public void test_set_RP_int_intarray_String_Locale() {
BaseDateTimeField field = new MockPreciseDateTimeField();
int[] values = new int[] { 10, 20, 30, 40 };
int[] expected = new int[] { 10, 20, 30, 40 };
int[] result = field.set(new TimeOfDay(), 2, values, "30", null);
assertEquals(true, Arrays.equals(result, expected));
values = new int[] { 10, 20, 30, 40 };
expected = new int[] { 10, 20, 29, 40 };
result = field.set(new TimeOfDay(), 2, values, "29", Locale.ENGLISH);
assertEquals(true, Arrays.equals(result, expected));
values = new int[] { 10, 20, 30, 40 };
expected = new int[] { 10, 20, 30, 40 };
try {
field.set(new TimeOfDay(), 2, values, "60", null);
fail();
} catch (IllegalArgumentException ex) {
}
assertEquals(true, Arrays.equals(values, expected));
values = new int[] { 10, 20, 30, 40 };
expected = new int[] { 10, 20, 30, 40 };
try {
field.set(new TimeOfDay(), 2, values, "-1", null);
fail();
} catch (IllegalArgumentException ex) {
}
assertEquals(true, Arrays.equals(values, expected));
}
use of org.joda.time.TimeOfDay in project joda-time by JodaOrg.
the class TestPreciseDurationDateTimeField method test_add_RP_int_intarray_int.
public void test_add_RP_int_intarray_int() {
int[] values = new int[] { 10, 20, 30, 40 };
int[] expected = new int[] { 10, 20, 30, 40 };
BaseDateTimeField field = new MockStandardBaseDateTimeField();
int[] result = field.add(new TimeOfDay(), 2, values, 0);
assertEquals(true, Arrays.equals(expected, result));
values = new int[] { 10, 20, 30, 40 };
expected = new int[] { 10, 20, 31, 40 };
result = field.add(new TimeOfDay(), 2, values, 1);
assertEquals(true, Arrays.equals(expected, result));
values = new int[] { 10, 20, 30, 40 };
expected = new int[] { 10, 21, 0, 40 };
result = field.add(new TimeOfDay(), 2, values, 30);
assertEquals(true, Arrays.equals(expected, result));
values = new int[] { 23, 59, 30, 40 };
try {
field.add(new TimeOfDay(), 2, values, 30);
fail();
} catch (IllegalArgumentException ex) {
}
values = new int[] { 10, 20, 30, 40 };
expected = new int[] { 10, 20, 29, 40 };
result = field.add(new TimeOfDay(), 2, values, -1);
assertEquals(true, Arrays.equals(expected, result));
values = new int[] { 10, 20, 30, 40 };
expected = new int[] { 10, 19, 59, 40 };
result = field.add(new TimeOfDay(), 2, values, -31);
assertEquals(true, Arrays.equals(expected, result));
values = new int[] { 0, 0, 30, 40 };
try {
field.add(new TimeOfDay(), 2, values, -31);
fail();
} catch (IllegalArgumentException ex) {
}
}
use of org.joda.time.TimeOfDay in project joda-time by JodaOrg.
the class TestPreciseDurationDateTimeField method test_set_RP_int_intarray_int.
public void test_set_RP_int_intarray_int() {
BaseDateTimeField field = new MockPreciseDurationDateTimeField();
int[] values = new int[] { 10, 20, 30, 40 };
int[] expected = new int[] { 10, 20, 30, 40 };
int[] result = field.set(new TimeOfDay(), 2, values, 30);
assertEquals(true, Arrays.equals(result, expected));
values = new int[] { 10, 20, 30, 40 };
expected = new int[] { 10, 20, 29, 40 };
result = field.set(new TimeOfDay(), 2, values, 29);
assertEquals(true, Arrays.equals(result, expected));
values = new int[] { 10, 20, 30, 40 };
expected = new int[] { 10, 20, 30, 40 };
try {
field.set(new TimeOfDay(), 2, values, 60);
fail();
} catch (IllegalArgumentException ex) {
}
assertEquals(true, Arrays.equals(values, expected));
values = new int[] { 10, 20, 30, 40 };
expected = new int[] { 10, 20, 30, 40 };
try {
field.set(new TimeOfDay(), 2, values, -1);
fail();
} catch (IllegalArgumentException ex) {
}
assertEquals(true, Arrays.equals(values, expected));
}
use of org.joda.time.TimeOfDay in project joda-time by JodaOrg.
the class TestPreciseDurationDateTimeField method test_addWrapField_RP_int_intarray_int.
public void test_addWrapField_RP_int_intarray_int() {
BaseDateTimeField field = new MockPreciseDurationDateTimeField();
int[] values = new int[] { 10, 20, 30, 40 };
int[] expected = new int[] { 10, 20, 30, 40 };
int[] result = field.addWrapField(new TimeOfDay(), 2, values, 0);
assertEquals(true, Arrays.equals(result, expected));
values = new int[] { 10, 20, 30, 40 };
expected = new int[] { 10, 20, 59, 40 };
result = field.addWrapField(new TimeOfDay(), 2, values, 29);
assertEquals(true, Arrays.equals(result, expected));
values = new int[] { 10, 20, 30, 40 };
expected = new int[] { 10, 20, 0, 40 };
result = field.addWrapField(new TimeOfDay(), 2, values, 30);
assertEquals(true, Arrays.equals(result, expected));
values = new int[] { 10, 20, 30, 40 };
expected = new int[] { 10, 20, 1, 40 };
result = field.addWrapField(new TimeOfDay(), 2, values, 31);
assertEquals(true, Arrays.equals(result, expected));
}
Aggregations