@@ -14,7 +14,7 @@ define( [
14
14
QUnit . module ( 'globeCoordinate.GlobeCoordinate.js' ) ;
15
15
16
16
QUnit . test ( 'Basic checks' , function ( assert ) {
17
- assert . expect ( 13 ) ;
17
+ assert . expect ( 10 ) ;
18
18
var c ;
19
19
20
20
assert . throws (
@@ -76,26 +76,26 @@ define( [
76
76
'string' ,
77
77
'Verified iso6709()'
78
78
) ;
79
+ } ) ;
79
80
80
- // test with no precision provided
81
- c = new globeCoordinate . GlobeCoordinate ( { latitude : 20 , longitude : 25.5 } ) ;
81
+ QUnit . test ( 'Precision defaults to null' , function ( assert ) {
82
+ assert . expect ( 3 ) ;
83
+ var c = new globeCoordinate . GlobeCoordinate ( { latitude : 0 , longitude : 0 } ) ;
82
84
83
- assert . equal (
84
- c . getLatitude ( ) ,
85
- 20 ,
86
- 'Verified getLatitude()'
85
+ assert . ok (
86
+ c . getPrecision ( ) === null ,
87
+ 'Verified getPrecision()'
87
88
) ;
88
89
89
- assert . equal (
90
- c . getLongitude ( ) ,
91
- 25.5 ,
92
- 'Verified getLatitude ()'
90
+ assert . deepEqual (
91
+ c . getDecimal ( ) ,
92
+ { latitude : 0 , longitude : 0 , precision : null } ,
93
+ 'Verified getDecimal ()'
93
94
) ;
94
95
95
- assert . equal (
96
- c . getPrecision ( ) ,
97
- null ,
98
- 'Verified precision is null'
96
+ assert . ok (
97
+ c . equals ( c ) ,
98
+ 'Validated equality'
99
99
) ;
100
100
} ) ;
101
101
@@ -119,6 +119,36 @@ define( [
119
119
) ;
120
120
} ) ;
121
121
122
+ QUnit . test ( 'ISO 6709 strings' , function ( assert ) {
123
+ assert . expect ( 12 ) ;
124
+ var gcDefs = [
125
+ { precision : 10 , expected : '+10+010/' } ,
126
+ { precision : 2 , expected : '+14+012/' } ,
127
+ { precision : 1 , expected : '+13+012/' } ,
128
+ { precision : 0.1 , expected : '+1307+01207/' } ,
129
+ { precision : 0.01 , expected : '+130724+0120724/' } ,
130
+ { precision : 1 / 60 , expected : '+1307+01207/' } ,
131
+ { precision : 1 / 3600 , expected : '+130724+0120724/' } ,
132
+ { precision : 1 / 36000 , expected : '+130724.4+0120724.4/' } ,
133
+ { precision : 1 / 360000 , expected : '+130724.42+0120724.42/' } ,
134
+ { precision : 0 , expected : '+130724.42+0120724.42/' } ,
135
+ { precision : null , expected : '+130724.42+0120724.42/' } ,
136
+ { expected : '+130724.42+0120724.42/' }
137
+ ] ,
138
+ c ;
139
+
140
+ $ . each ( gcDefs , function ( i , gcDef ) {
141
+ c = new globeCoordinate . GlobeCoordinate (
142
+ { latitude : 13.12345 , longitude : 12.12345 , precision : gcDef . precision }
143
+ ) ;
144
+
145
+ assert . ok (
146
+ c . iso6709 ( ) === gcDef . expected ,
147
+ 'Validated ISO 6709 string of data set #' + i + '.'
148
+ ) ;
149
+ } ) ;
150
+ } ) ;
151
+
122
152
QUnit . test ( 'Strict (in)equality' , function ( assert ) {
123
153
assert . expect ( 169 ) ;
124
154
var gcDefs = [
0 commit comments