Skip to content

Commit 56c633c

Browse files
committed
Fix BoundingBox.width return value.
We now return the correct value. Closes #2526
1 parent 2692aaf commit 56c633c

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

src/main/java/org/springframework/data/redis/domain/geo/BoundingBox.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public BoundingBox(double width, double height, Metric metric) {
7070
* @return will never be {@literal null}.
7171
*/
7272
public Distance getWidth() {
73-
return height;
73+
return width;
7474
}
7575

7676
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.redis.domain.geo;
17+
18+
import static org.assertj.core.api.Assertions.*;
19+
20+
import org.junit.jupiter.api.Test;
21+
import org.springframework.data.geo.Distance;
22+
23+
/**
24+
* Unit tests for {@link BoundingBox}.
25+
*
26+
* @author Mark Paluch
27+
*/
28+
class BoundingBoxUnitTests {
29+
30+
@Test // GH-2526
31+
void shouldReturnCorrectValues() {
32+
33+
Distance w = new Distance(1);
34+
Distance h = new Distance(2);
35+
BoundingBox box = new BoundingBox(w, h);
36+
37+
assertThat(box.getWidth()).isEqualTo(w);
38+
assertThat(box.getHeight()).isEqualTo(h);
39+
}
40+
41+
@Test // GH-2526
42+
void shouldEqual() {
43+
44+
Distance w = new Distance(1);
45+
Distance h = new Distance(2);
46+
BoundingBox box1 = new BoundingBox(w, h);
47+
BoundingBox box2 = new BoundingBox(w, h);
48+
49+
assertThat(box1).isEqualTo(box2).hasSameHashCodeAs(box2);
50+
}
51+
}

0 commit comments

Comments
 (0)