1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.joda.time;
17
18 import org.joda.time.chrono.ISOChronology;
19
20 import junit.framework.TestCase;
21 import junit.framework.TestSuite;
22
23
24
25
26
27
28 public class TestDurationField extends TestCase {
29
30 public static void main(String[] args) {
31 junit.textui.TestRunner.run(suite());
32 }
33
34 public static TestSuite suite() {
35 return new TestSuite(TestDurationField.class);
36 }
37
38 public TestDurationField(String name) {
39 super(name);
40 }
41
42 protected void setUp() throws Exception {
43 }
44
45 protected void tearDown() throws Exception {
46 }
47
48
49 public void test_subtract() throws Exception {
50 DurationField fld = ISOChronology.getInstanceUTC().millis();
51 assertEquals(900, fld.subtract(1000L, 100));
52 assertEquals(900L, fld.subtract(1000L, 100L));
53 assertEquals((1000L - Integer.MAX_VALUE), fld.subtract(1000L, Integer.MAX_VALUE));
54 assertEquals((1000L - Integer.MIN_VALUE), fld.subtract(1000L, Integer.MIN_VALUE));
55 assertEquals((1000L - Long.MAX_VALUE), fld.subtract(1000L, Long.MAX_VALUE));
56 try {
57 fld.subtract(-1000L, Long.MIN_VALUE);
58 fail();
59 } catch (ArithmeticException ex) {}
60 }
61
62 }