aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/geojson/LngLatAltTest.java
blob: 7045de7ae3c6c6480573ad437eb10deba31ed85c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package org.geojson;

import org.junit.Assert;
import org.junit.Test;

public class LngLatAltTest {

	@Test
	public void should_LngLatAlt_equals_without_alt() {
		LngLatAlt first = new LngLatAlt(14.D, 13.D);
		LngLatAlt second = new LngLatAlt(14.D, 13.D);
		Assert.assertEquals(second, first);
	}

	@Test
	public void should_LngLatAlt_equals_with_alt() {
		LngLatAlt first = new LngLatAlt(14.D, 13.D, 15D);
		LngLatAlt second = new LngLatAlt(14.D, 13.D, 15D);
		Assert.assertEquals(second, first);
	}

	@Test
	public void should_not_LngLatAlt_equals_with_alt() {
		LngLatAlt first = new LngLatAlt(14.D, 13.D, 15D);
		LngLatAlt second = new LngLatAlt(14.D, 13.D, 16D);
		Assert.assertNotEquals(second, first);
	}

	@Test
	public void should_not_LngLatAlt_equals_without_alt() {
		LngLatAlt first = new LngLatAlt(14.D, 14.D, 15D);
		LngLatAlt second = new LngLatAlt(14.D, 13.D, 16D);
		Assert.assertNotEquals(second, first);
	}

	@Test
	public void should_LngLatAlt_equals_with_additional_elements() {
		LngLatAlt first = new LngLatAlt(14.D, 14.D, 15D, 16D, 17D);
		LngLatAlt second = new LngLatAlt(14.D, 14.D, 15D, 16D, 17D);
		Assert.assertEquals(second, first);
		Assert.assertEquals(second.hashCode(), first.hashCode());
	}

	@Test
	public void should_LngLatAlt_equals_with_additional_elements_and_null() {
		LngLatAlt first = new LngLatAlt(14.D, 14.D, 15D, 16D, 17D);
		LngLatAlt second = new LngLatAlt(14.D, 14.D, 15D, 16D, 17D);
		Assert.assertEquals(second, first);
		Assert.assertEquals(second.hashCode(), first.hashCode());
	}

	@Test
	public void should_not_LngLatAlt_equals_without_additional_elements() {
		LngLatAlt first = new LngLatAlt(14.D, 14.D, 15D, 16D, 17D);
		LngLatAlt second = new LngLatAlt(14.D, 14.D, 15D);
		Assert.assertNotEquals(second, first);
		Assert.assertNotEquals(second.hashCode(), first.hashCode());
	}

	@Test
	public void should_not_LngLatAlt_equals_with_additional_elements_in_different_order() {
		LngLatAlt first = new LngLatAlt(14.D, 14.D, 15D, 16D, 17D);
		LngLatAlt second = new LngLatAlt(14.D, 14.D, 15D, 17D, 16D);
		Assert.assertNotEquals(second, first);
		Assert.assertNotEquals(second.hashCode(), first.hashCode());
	}

	@Test
	public void should_not_LngLatAlt_equals_with_additional_elements_and_different_size() {
		LngLatAlt first = new LngLatAlt(14.D, 14.D, 15D, 16D, 17D);
		LngLatAlt second = new LngLatAlt(14.D, 14.D, 15D, 16D, 17D, 18D);
		Assert.assertNotEquals(second, first);
		Assert.assertNotEquals(second.hashCode(), first.hashCode());
	}

	@Test
	public void should_LngLatAlt_throw_if_alt_not_specified_in_constructor() {
		try {
			new LngLatAlt(14.D, 14.D, Double.NaN, 16D, 17D);
			Assert.fail("Additional elements are not allowed if altitude is Nan.");
		} catch (IllegalArgumentException e) {
			Assert.assertTrue("Expected exception.", true);
		}
	}

	@Test
	public void should_LngLatAlt_throw_if_alt_set_to_Nan_with_additional_elements() {
		LngLatAlt lngLatAlt = new LngLatAlt(14.D, 14.D, 15.D, 16D, 17D);

		try {
			lngLatAlt.setAltitude(Double.NaN);
			Assert.fail("Additional elements are not allowed if altitude is Nan.");
		} catch (IllegalArgumentException e) {
			Assert.assertTrue("Expected exception.", true);
		}
	}

	@Test
	public void should_LngLatAlt_throw_if_additional_elements_set_with_missing_alt() {
		LngLatAlt lngLatAlt = new LngLatAlt(14.D, 14.D);

		try {
			lngLatAlt.setAdditionalElements(42);
			Assert.fail("Additional elements are not allowed if altitude is Nan.");
		} catch (IllegalArgumentException e) {
			Assert.assertTrue("Expected exception.", true);
		}
	}

	@Test
	public void should_LngLatAlt_throw_if_additional_elements_set_with_Nan_alt() {
		LngLatAlt lngLatAlt = new LngLatAlt(14.D, 14.D, Double.NaN);

		try {
			lngLatAlt.setAdditionalElements(42);
			Assert.fail("Additional elements are not allowed if altitude is Nan.");
		} catch (IllegalArgumentException e) {
			Assert.assertTrue("Expected exception.", true);
		}
	}

	@Test
	public void should_LngLatAlt_throw_if_any_additional_elements_constructed_to_Nan() {
		try {
			new LngLatAlt(14.D, 14.D, 15.D, 16.D, Double.NaN, 17.D);
			Assert.fail("Additional elements are not allowed to be Nan.");
		} catch (IllegalArgumentException e) {
			Assert.assertTrue("Expected exception.", true);
		}
	}

	@Test
	public void should_LngLatAlt_throw_if_any_additional_elements_constructed_to_Positive_Infinity() {
		try {
			new LngLatAlt(14.D, 14.D, 15.D, 16.D, Double.POSITIVE_INFINITY, 17.D);
			Assert.fail("Additional elements are not allowed to be positive infinity.");
		} catch (IllegalArgumentException e) {
			Assert.assertTrue("Expected exception.", true);
		}
	}

	@Test
	public void should_LngLatAlt_throw_if_any_additional_elements_constructed_to_Negative_Infinity() {
		try {
			new LngLatAlt(14.D, 14.D, 15.D, 16.D, Double.NEGATIVE_INFINITY, 17.D);
			Assert.fail("Additional elements are not allowed to be positive infinity.");
		} catch (IllegalArgumentException e) {
			Assert.assertTrue("Expected exception.", true);
		}
	}

	@Test
	public void should_LngLatAlt_throw_if_any_additional_elements_set_to_Nan() {
		LngLatAlt lngLatAlt = new LngLatAlt(14.D, 14.D, 15.D);
		try {
			lngLatAlt.setAdditionalElements(16.D, Double.NaN, 17.D);
			Assert.fail("Additional elements are not allowed to be Nan.");
		} catch (IllegalArgumentException e) {
			Assert.assertTrue("Expected exception.", true);
		}
	}

	@Test
	public void should_LngLatAlt_throw_if_any_additional_elements_set_to_Positive_Infinity() {
		LngLatAlt lngLatAlt = new LngLatAlt(14.D, 14.D, 15.D);
		try {
			lngLatAlt.setAdditionalElements(16.D, Double.POSITIVE_INFINITY, 17.D);
			Assert.fail("Additional elements are not allowed to be positive infinity.");
		} catch (IllegalArgumentException e) {
			Assert.assertTrue("Expected exception.", true);
		}
	}

	@Test
	public void should_LngLatAlt_throw_if_any_additional_elements_set_to_Negative_Infinity() {
		LngLatAlt lngLatAlt = new LngLatAlt(14.D, 14.D, 15.D);
		try {
			lngLatAlt.setAdditionalElements(16.D, Double.NEGATIVE_INFINITY, 17.D);
			Assert.fail("Additional elements are not allowed to be positive infinity.");
		} catch (IllegalArgumentException e) {
			Assert.assertTrue("Expected exception.", true);
		}
	}
}