@@ -145,129 +145,134 @@ mod tests {
145
145
use pg_interval:: Interval ;
146
146
147
147
#[ test]
148
- fn test_iso_1 ( ) {
148
+ fn test_from_iso_1 ( ) {
149
149
let interval = Interval :: from_iso ( "P1Y" ) . unwrap ( ) ;
150
150
let interval_exp = Interval :: new ( 12 , 0 , 0 ) ;
151
151
assert_eq ! ( interval, interval_exp) ;
152
152
}
153
153
154
- /*
154
+
155
155
#[ test]
156
- fn test_8601_2 () {
157
- let interval = Interval::new(13, 0, 0 );
158
- let output = interval.to_iso_8601( );
159
- assert_eq!(String::from("P1Y1M"), output );
156
+ fn test_from_8601_2 ( ) {
157
+ let interval = Interval :: from_iso ( "P1Y1M" ) . unwrap ( ) ;
158
+ let interval_exp = Interval :: new ( 13 , 0 , 0 ) ;
159
+ assert_eq ! ( interval , interval_exp ) ;
160
160
}
161
161
162
+
162
163
#[ test]
163
- fn test_8601_3 () {
164
- let interval = Interval::new(13, 1, 0 );
165
- let output = interval.to_iso_8601( );
166
- assert_eq!(String::from("P1Y1M1D"), output );
164
+ fn test_from_8601_3 ( ) {
165
+ let interval = Interval :: from_iso ( "P1Y1M1D" ) . unwrap ( ) ;
166
+ let interval_exp = Interval :: new ( 13 , 1 , 0 ) ;
167
+ assert_eq ! ( interval , interval_exp ) ;
167
168
}
168
169
169
170
#[ test]
170
- fn test_8601_4 () {
171
- let interval = Interval::new(13, 1, 3600000000 );
172
- let output = interval.to_iso_8601( );
173
- assert_eq!(String::from("P1Y1M1DT1H"), output );
171
+ fn test_from_8601_4 ( ) {
172
+ let interval = Interval :: from_iso ( "P1Y1M1DT1H" ) . unwrap ( ) ;
173
+ let interval_exp = Interval :: new ( 13 , 1 , 3600000000 ) ;
174
+ assert_eq ! ( interval , interval_exp ) ;
174
175
}
175
176
177
+
176
178
#[ test]
177
- fn test_8601_5 () {
178
- let interval = Interval::new(13, 1, 4200000000 );
179
- let output = interval.to_iso_8601( );
180
- assert_eq!(String::from("P1Y1M1DT1H10M"), output );
179
+ fn test_from_8601_5 ( ) {
180
+ let interval = Interval :: from_iso ( "P1Y1M1DT1H10M" ) . unwrap ( ) ;
181
+ let interval_exp = Interval :: new ( 13 , 1 , 4200000000 ) ;
182
+ assert_eq ! ( interval , interval_exp ) ;
181
183
}
182
184
185
+
183
186
#[ test]
184
- fn test_8601_6 () {
185
- let interval = Interval::new(13, 1, 4215000000 );
186
- let output = interval.to_iso_8601( );
187
- assert_eq!(String::from("P1Y1M1DT1H10M15S"), output );
187
+ fn test_from_8601_6 ( ) {
188
+ let interval = Interval :: from_iso ( "P1Y1M1DT1H10M15S" ) . unwrap ( ) ;
189
+ let interval_exp = Interval :: new ( 13 , 1 , 4215000000 ) ;
190
+ assert_eq ! ( interval , interval_exp ) ;
188
191
}
189
192
190
193
#[ test]
191
- fn test_8601_7 () {
192
- let interval = Interval::new(0, 0, 3600000000 );
193
- let output = interval.to_iso_8601( );
194
- assert_eq!(String::from("PT1H"), output );
194
+ fn test_from_8601_7 ( ) {
195
+ let interval = Interval :: from_iso ( "PT1H" ) . unwrap ( ) ;
196
+ let interval_exp = Interval :: new ( 0 , 0 , 3600000000 ) ;
197
+ assert_eq ! ( interval , interval_exp ) ;
195
198
}
196
199
197
200
#[ test]
198
- fn test_8601_8 () {
199
- let interval = Interval::new(0, 0, 4200000000 );
200
- let output = interval.to_iso_8601( );
201
- assert_eq!(String::from("PT1H10M"), output );
201
+ fn test_from_8601_8 ( ) {
202
+ let interval = Interval :: from_iso ( "PT1H10M" ) . unwrap ( ) ;
203
+ let interval_exp = Interval :: new ( 0 , 0 , 4200000000 ) ;
204
+ assert_eq ! ( interval , interval_exp ) ;
202
205
}
203
206
207
+
204
208
#[ test]
205
- fn test_8601_9 () {
206
- let interval = Interval::new(0, 0, 4215000000 );
207
- let output = interval.to_iso_8601( );
208
- assert_eq!(String::from("PT1H10M15S"), output );
209
+ fn test_from_8601_9 ( ) {
210
+ let interval = Interval :: from_iso ( "PT1H10M15S" ) . unwrap ( ) ;
211
+ let interval_exp = Interval :: new ( 0 , 0 , 4215000000 ) ;
212
+ assert_eq ! ( interval , interval_exp ) ;
209
213
}
210
214
211
215
#[ test]
212
- fn test_8601_10 () {
213
- let interval = Interval::new(-12, 0, 0 );
214
- let output = interval.to_iso_8601( );
215
- assert_eq!(String::from("P-1Y"), output );
216
+ fn test_from_8601_10 ( ) {
217
+ let interval = Interval :: from_iso ( "P-1Y" ) . unwrap ( ) ;
218
+ let interval_exp = Interval :: new ( - 12 , 0 , 0 ) ;
219
+ assert_eq ! ( interval , interval_exp ) ;
216
220
}
217
221
222
+
218
223
#[ test]
219
- fn test_8601_11 () {
220
- let interval = Interval::new(-13, 0, 0 );
221
- let output = interval.to_iso_8601( );
222
- assert_eq!(String::from("P-1Y-1M"), output );
224
+ fn test_from_8601_11 ( ) {
225
+ let interval = Interval :: from_iso ( "P-1Y-1M" ) . unwrap ( ) ;
226
+ let interval_exp = Interval :: new ( - 13 , 0 , 0 ) ;
227
+ assert_eq ! ( interval , interval_exp ) ;
223
228
}
224
229
225
230
#[ test]
226
- fn test_8601_12 () {
227
- let interval = Interval::new(-13, -1, 0 );
228
- let output = interval.to_iso_8601( );
229
- assert_eq!(String::from("P-1Y-1M-1D"), output );
231
+ fn test_from_8601_12 ( ) {
232
+ let interval = Interval :: from_iso ( "P-1Y-1M-1D" ) . unwrap ( ) ;
233
+ let interval_exp = Interval :: new ( - 13 , - 1 , 0 ) ;
234
+ assert_eq ! ( interval , interval_exp ) ;
230
235
}
231
236
232
237
#[ test]
233
- fn test_8601_13 () {
234
- let interval = Interval::new(-13, -1, -3600000000 );
235
- let output = interval.to_iso_8601( );
236
- assert_eq!(String::from("P-1Y-1M-1DT-1H"), output );
238
+ fn test_from_8601_13 ( ) {
239
+ let interval = Interval :: from_iso ( "P-1Y-1M-1DT-1H" ) . unwrap ( ) ;
240
+ let interval_exp = Interval :: new ( - 13 , - 1 , - 3600000000 ) ;
241
+ assert_eq ! ( interval , interval_exp ) ;
237
242
}
238
243
239
244
#[ test]
240
- fn test_8601_14 () {
241
- let interval = Interval::new(-13, -1, -4200000000 );
242
- let output = interval.to_iso_8601( );
243
- assert_eq!(String::from("P-1Y-1M-1DT-1H-10M"), output );
245
+ fn test_from_8601_14 ( ) {
246
+ let interval = Interval :: from_iso ( "P-1Y-1M-1DT-1H-10M" ) . unwrap ( ) ;
247
+ let interval_exp = Interval :: new ( - 13 , - 1 , - 4200000000 ) ;
248
+ assert_eq ! ( interval , interval_exp ) ;
244
249
}
245
250
246
251
#[ test]
247
- fn test_8601_15 () {
248
- let interval = Interval::new(-13, -1, -4215000000 );
249
- let output = interval.to_iso_8601( );
250
- assert_eq!(String::from("P-1Y-1M-1DT-1H-10M-15S"), output );
252
+ fn test_from_8601_15 ( ) {
253
+ let interval = Interval :: from_iso ( "P-1Y-1M-1DT-1H-10M-15S" ) . unwrap ( ) ;
254
+ let interval_exp = Interval :: new ( - 13 , - 1 , - 4215000000 ) ;
255
+ assert_eq ! ( interval , interval_exp ) ;
251
256
}
252
257
253
258
#[ test]
254
- fn test_8601_16 () {
255
- let interval = Interval::new(0, 0, -3600000000 );
256
- let output = interval.to_iso_8601( );
257
- assert_eq!(String::from("PT-1H"), output );
259
+ fn test_from_8601_16 ( ) {
260
+ let interval = Interval :: from_iso ( "PT-1H" ) . unwrap ( ) ;
261
+ let interval_exp = Interval :: new ( 0 , 0 , - 3600000000 ) ;
262
+ assert_eq ! ( interval , interval_exp ) ;
258
263
}
259
264
260
265
#[ test]
261
- fn test_8601_17 () {
262
- let interval = Interval::new(0, 0, -4200000000 );
263
- let output = interval.to_iso_8601( );
264
- assert_eq!(String::from("PT-1H-10M"), output );
266
+ fn test_from_8601_17 ( ) {
267
+ let interval = Interval :: from_iso ( "PT-1H-10M" ) . unwrap ( ) ;
268
+ let interval_exp = Interval :: new ( 0 , 0 , - 4200000000 ) ;
269
+ assert_eq ! ( interval , interval_exp ) ;
265
270
}
266
271
267
272
#[ test]
268
- fn test_8601_18 () {
269
- let interval = Interval::new(0, 0, -4215000000 );
270
- let output = interval.to_iso_8601( );
271
- assert_eq!(String::from("PT-1H-10M-15S"), output );
272
- } */
273
+ fn test_from_8601_18 ( ) {
274
+ let interval = Interval :: from_iso ( "PT-1H-10M-15S" ) . unwrap ( ) ;
275
+ let interval_exp = Interval :: new ( 0 , 0 , - 4215000000 ) ;
276
+ assert_eq ! ( interval , interval_exp ) ;
277
+ }
273
278
}
0 commit comments