summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Patrick Valsecchi <patrick@thus.ch>2015-02-23 13:38:41 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-23 05:37:34 -0800
commitce79b9ffa4062cc3976838cb9a5fedd31f2f3614 (patch)
tree8d5ab0a1af6ac06d23ba8e309aaeb121c7d4eac8 /tests
parent0f6f1c7ccf77d053db053f66fc3e41e016f1597b (diff)
downloadsubsurface-ce79b9ffa4062cc3976838cb9a5fedd31f2f3614.tar.gz
Add support for more GPS coordinate formats.
As requested in the user forum and in the mailing list, now support: - 46.473881 6.784696 (format used in XML files) - 48 51.491n 2 17.677e I was not able to handle the XML format in a generic way without making the code too ugly. So I've added an exception. Signed-off-by: Patrick Valsecchi <patrick@thus.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/testgpscoords.cpp23
-rw-r--r--tests/testgpscoords.h4
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/testgpscoords.cpp b/tests/testgpscoords.cpp
index a38dcc807..c5a4d22a4 100644
--- a/tests/testgpscoords.cpp
+++ b/tests/testgpscoords.cpp
@@ -77,6 +77,29 @@ void TestGpsCoords::testSpaceDecimalParse()
coord2double(52.83), coord2double(1.61));
}
+void TestGpsCoords::testXmlFormatParse()
+{
+ testParseOK("46.473881 6.784696",
+ coord2double(46.473881), coord2double(6.784696));
+}
+
+void TestGpsCoords::testNegativeXmlFormatParse()
+{
+ testParseOK("46.473881 -6.784696",
+ coord2double(46.473881), -coord2double(6.784696));
+}
+
+void TestGpsCoords::testNoUnitParse()
+{
+ testParseOK("48 51.491n 2 17.677e",
+ coord2double(48, 51.491), coord2double(2, 17.677));
+}
+
+void TestGpsCoords::testPrefixNoUnitParse()
+{
+ testParseOK("n48 51.491 w2 17.677",
+ coord2double(48, 51.491), -coord2double(2, 17.677));
+}
void TestGpsCoords::testParseOK(const QString &txt, double expectedLat,
double expectedLon)
diff --git a/tests/testgpscoords.h b/tests/testgpscoords.h
index 5add3da93..784bc302e 100644
--- a/tests/testgpscoords.h
+++ b/tests/testgpscoords.h
@@ -18,6 +18,10 @@ private slots:
void testDecimalParse();
void testSpaceDecimalParse();
void testDecimalInversedParse();
+ void testXmlFormatParse();
+ void testNoUnitParse();
+ void testNegativeXmlFormatParse();
+ void testPrefixNoUnitParse();
private:
static void testParseOK(const QString &txt, double expectedLat,