aboutsummaryrefslogtreecommitdiffstats
path: root/t/utils.t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@dracos.co.uk>2011-03-25 15:25:06 +0000
committerMatthew Somerville <matthew@dracos.co.uk>2011-03-25 15:25:06 +0000
commitf931e2f7146ee271807315a9830c71afc8ad6eb5 (patch)
tree042b0fd56636fdefde655b2e5d62d210a3d4776f /t/utils.t
parent71c4b7a598c6b0b441eef63b1e1e016bd45e9991 (diff)
parent8db1506fb88902e70350d15ba9484180c9d9b3bb (diff)
Merge branch 'master' into reportemptyhomes
Conflicts: web/css/cobrands/emptyhomes/emptyhomes.css
Diffstat (limited to 't/utils.t')
-rw-r--r--t/utils.t41
1 files changed, 41 insertions, 0 deletions
diff --git a/t/utils.t b/t/utils.t
new file mode 100644
index 000000000..385c482ed
--- /dev/null
+++ b/t/utils.t
@@ -0,0 +1,41 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Test::More tests => 9;
+
+use FindBin;
+use lib "$FindBin::Bin/../perllib";
+use lib "$FindBin::Bin/../commonlib/perllib";
+
+use Utils;
+
+my @truncate_tests = (
+ [ '1.1234567890123', '1.123457', "truncate down" ],
+ [ '1.123456', '1.123456', "leave untouched" ],
+ [ '1.12', '1.12', "don't extend" ],
+ [ '1.100000001', '1.1', "knock off trailing zeros" ],
+ [ '1.000000001', '1', "knock off trailing zeros" ],
+ [ '0.0', '0', "knock off trailing zeros" ],
+ [ '+123', '123', "drop plus sign" ],
+ [ '-123', '-123', "keep minus sign" ],
+);
+
+foreach my $test (@truncate_tests) {
+ my ( $in, $out, $msg ) = @$test;
+ is Utils::truncate_coordinate($in), $out, $msg;
+}
+
+my @convert_en_to_latlon_tests = (
+
+ # e n lat lon
+ [ 1234, 4567, 49.808509, -7.544784 ],
+);
+
+foreach my $test (@convert_en_to_latlon_tests) {
+ my ( $e, $n, $lat, $lon ) = @$test;
+ is_deeply #
+ [ Utils::convert_en_to_latlon_truncated( $e, $n ) ], #
+ [ $lat, $lon ], #
+ "convert ($e,$n) to ($lat,$lon)";
+}