aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/geopoint/ViewportTest.java
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2014-01-08 13:26:24 +0100
committerSamuel Tardieu <sam@rfc1149.net>2014-01-08 13:50:16 +0100
commit20232a47f33653f0950663c4e96467f4de60e303 (patch)
treec24cf430c10fd29f96be353fc496a6a98064deb0 /tests/src/cgeo/geocaching/geopoint/ViewportTest.java
parentdc577d523fb9ff69f28b94ae1e369e46e778f08f (diff)
downloadcgeo-20232a47f33653f0950663c4e96467f4de60e303.zip
cgeo-20232a47f33653f0950663c4e96467f4de60e303.tar.gz
cgeo-20232a47f33653f0950663c4e96467f4de60e303.tar.bz2
fix #3527: bad query string
Let's hope that the bad formatting occurring for, at least, very small negative values in `String.format()` with a `null` Locale will not happen with `StringBuilder.append(double)`.
Diffstat (limited to 'tests/src/cgeo/geocaching/geopoint/ViewportTest.java')
-rw-r--r--tests/src/cgeo/geocaching/geopoint/ViewportTest.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/src/cgeo/geocaching/geopoint/ViewportTest.java b/tests/src/cgeo/geocaching/geopoint/ViewportTest.java
index ac32468..60766b4 100644
--- a/tests/src/cgeo/geocaching/geopoint/ViewportTest.java
+++ b/tests/src/cgeo/geocaching/geopoint/ViewportTest.java
@@ -6,6 +6,7 @@ import android.test.AndroidTestCase;
import java.util.Collections;
import java.util.HashSet;
+import java.util.Locale;
import java.util.Set;
public class ViewportTest extends AndroidTestCase {
@@ -54,8 +55,17 @@ public class ViewportTest extends AndroidTestCase {
}
public static void testSqlWhere() {
- assertEquals("latitude >= -1.0 and latitude <= 3.0 and longitude >= -2.0 and longitude <= 4.0", vpRef.sqlWhere(null));
- assertEquals("t.latitude >= -1.0 and t.latitude <= 3.0 and t.longitude >= -2.0 and t.longitude <= 4.0", vpRef.sqlWhere("t"));
+ assertEquals("latitude >= -1.0 and latitude <= 3.0 and longitude >= -2.0 and longitude <= 4.0", vpRef.sqlWhere(null).toString());
+ assertEquals("t.latitude >= -1.0 and t.latitude <= 3.0 and t.longitude >= -2.0 and t.longitude <= 4.0", vpRef.sqlWhere("t").toString());
+ Locale current = null;
+ try {
+ current = Locale.getDefault();
+ Locale.setDefault(Locale.FRENCH);
+ assertEquals("1,0", String.format("%.2g", 1.0d)); // Control that we are in a locale with commma separator
+ assertEquals("t.latitude >= -1.0 and t.latitude <= 3.0 and t.longitude >= -2.0 and t.longitude <= 4.0", vpRef.sqlWhere("t").toString());
+ } finally {
+ Locale.setDefault(current);
+ }
}
public static void testEquals() {