superp-phone 1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,129 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
+
3
+ ## Portugal
4
+ # source 1: http://pt.wikipedia.org/wiki/N%C3%BAmeros_de_telefone_em_Portugal
5
+ # source 2: http://www.anacom.pt/render.jsp?categoryId=279035
6
+
7
+ class PTTest < Phoner::TestCase
8
+
9
+ ### Prefixes followed by corresponding tests
10
+
11
+ ## 01-09: reserved for future use
12
+ ## 1: Short Numbers
13
+
14
+ ## 2: Landline / fixed numbers
15
+
16
+ ## two digits landlines
17
+ # 21: Lisbon (Lisboa)
18
+ def test_lisbon
19
+ parse_test('+351 21 123 4567', '351', '21', '1234567')
20
+ end
21
+ # 22: Oporto (Porto)
22
+ def test_oporto
23
+ parse_test('+351 22 123 4567', '351', '22', '1234567')
24
+ end
25
+
26
+ ## three digits landlines
27
+ # 231: Mealhada
28
+ def test_mealhada
29
+ parse_test('+351 231 123456', '351', '231', '123456')
30
+ end
31
+
32
+ # 232-295 (Viseu - Angra do Heroismo)
33
+ def test_viseu
34
+ parse_test('+351 232 123456', '351', '232', '123456')
35
+ end
36
+ def test_angra
37
+ parse_test('+351 295 123456', '351', '295', '123456')
38
+ end
39
+
40
+ # 296: Ponta Delgada
41
+ def test_pontadelgada
42
+ parse_test('+351 296 123456', '351', '296', '123456')
43
+ end
44
+
45
+ ## 3: Nomad services
46
+ ## 4: Not used
47
+ ## 5: Free
48
+ ## 6: Audiotext service, data network access...
49
+
50
+ ## 7: Premium numbers ("Universal access numbers")
51
+
52
+ # 707-708: Premium Numbers
53
+ def test_707
54
+ Phoner::Phone.default_country_code = '351'
55
+ parse_test('707 123 456', '351', '707', '123456')
56
+ end
57
+
58
+ ## 8: Free toll numbers
59
+
60
+ # 800: Numero verde ("Green Number")
61
+ def test_800
62
+ Phoner::Phone.default_country_code = '351'
63
+ parse_test('800 123 456', '351', '800', '123456')
64
+ end
65
+ # 808: Numero azul ("Blue Number")
66
+ def test_808
67
+ Phoner::Phone.default_country_code = '351'
68
+ parse_test('808 123 456', '351', '808', '123456')
69
+ end
70
+ # 809: Custo partilhado ("Shared cost")
71
+ def test_809
72
+ Phoner::Phone.default_country_code = '351'
73
+ parse_test('809 123 456', '351', '809', '123456', 'Portugal', false)
74
+ end
75
+
76
+ ## 9: Mobile networks
77
+
78
+ ## two-digits mobile networks
79
+ # 91: Vodafone
80
+ def test_vodafone
81
+ parse_test('+351 91 1234567', '351', '91', '1234567', 'Portugal', true)
82
+ end
83
+ # 93: Optimus
84
+ def test_optimus
85
+ parse_test('+351 93 1234567', '351', '93', '1234567')
86
+ end
87
+ # 96: TMN two-digits
88
+ def test_tmn
89
+ parse_test('+351 96 1234567', '351', '96', '1234567')
90
+ end
91
+
92
+ ## three-digits mobile networks
93
+ # 921: TMN three-digits
94
+ def test_tmn921
95
+ parse_test('+351 921 123456', '351', '921', '123456')
96
+ end
97
+ # 923-926: TMN three-digits (corporate networks)
98
+ def test_tmn923
99
+ parse_test('+351 925 123456', '351', '925', '123456')
100
+ end
101
+ # 922: Phone-ix
102
+ def test_phoneix
103
+ parse_test('+351 922 123456', '351', '922', '123456')
104
+ end
105
+ # 929: Zon Mobile
106
+ def test_zonmobile
107
+ parse_test('+351 929 123456', '351', '929', '123456')
108
+ end
109
+
110
+ def test_validates
111
+ Phoner::Phone.default_country_code = nil
112
+ assert_equal Phoner::Phone.valid?('00351211234567'), true
113
+ assert_equal Phoner::Phone.valid?('00351911234567'), true
114
+ assert_equal Phoner::Phone.valid?('+351931234567'), true
115
+ assert_equal Phoner::Phone.valid?('+351 (911) 123 456'), true
116
+ assert_equal Phoner::Phone.valid?('+351921123456'), true
117
+
118
+ Phoner::Phone.default_country_code = '351'
119
+ assert_equal Phoner::Phone.valid?('(931) 234-567'), true
120
+ assert_equal Phoner::Phone.valid?('(211) 234 567'), true
121
+ assert_equal Phoner::Phone.valid?('232-123-456'), true
122
+ assert_equal Phoner::Phone.valid?('232123456'), true
123
+ assert_equal Phoner::Phone.valid?('92 212 34 56'), true
124
+ assert_equal Phoner::Phone.valid?('221234567'), true
125
+ assert_equal Phoner::Phone.valid?('708123456'), true
126
+ assert_equal Phoner::Phone.valid?('800 123 456'), true
127
+ end
128
+
129
+ end
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
+
3
+ ## Serbia
4
+ class RSTest < Phoner::TestCase
5
+
6
+ def test_local
7
+ # Beograd
8
+ parse_test('+381 11 24 33 836', '381', '11', '2433836', "Serbia", false)
9
+ end
10
+
11
+ def test_mobile
12
+ # mts
13
+ parse_test('+381 648542987', '381', '64', '8542987', "Serbia", true)
14
+ end
15
+ end
@@ -0,0 +1,478 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
+
3
+ ## Sweden
4
+ class SETest < Phoner::TestCase
5
+
6
+ # 08 Greater Stockholm
7
+ def test_stockholm
8
+ parse_test('+4685555555', '46', '8', '5555555')
9
+ end
10
+
11
+ ## two digit codes
12
+
13
+ # 010 Geographically Independent Numbers / VOIP services
14
+ def test_independent_numbers
15
+ parse_test('+46105555555', '46', '10', '5555555')
16
+ end
17
+
18
+ # 011 Norrköping
19
+ def test_norrkoping
20
+ parse_test('+46115555555', '46', '11', '5555555')
21
+ end
22
+
23
+ # 013 Linköping
24
+ def test_linkoping
25
+ parse_test('+46135555555', '46', '13', '5555555')
26
+ end
27
+
28
+ # 016 Eskilstuna-Torshälla
29
+ def test_eskilstuna
30
+ parse_test('+46165555555', '46', '16', '5555555')
31
+ end
32
+
33
+ # 018 Uppsala
34
+ def test_uppsala
35
+ parse_test('+46185555555', '46', '18', '5555555')
36
+ end
37
+
38
+ # 019 Örebro-Kumla
39
+ def test_orebro
40
+ parse_test('+46195555555', '46', '19', '5555555')
41
+ end
42
+
43
+ # 020 toll-free
44
+ def test_toll_free
45
+ parse_test('+46205555555', '46', '20', '5555555')
46
+ end
47
+
48
+ # 021 Västerås
49
+ def test_vasteras
50
+ parse_test('+46215555555', '46', '21', '5555555')
51
+ end
52
+
53
+ # 023 Falun
54
+ def test_falun
55
+ parse_test('+46235555555', '46', '23', '5555555')
56
+ end
57
+
58
+ # 026 Gävle-Sandviken
59
+ def test_gavle
60
+ parse_test('+46265555555', '46', '26', '5555555')
61
+ end
62
+
63
+ # 031 Göteborg
64
+ def test_goteborg
65
+ parse_test('+46315555555', '46', '31', '5555555')
66
+ end
67
+
68
+ # 033 Borås
69
+ def test_boras
70
+ parse_test('+46335555555', '46', '33', '5555555')
71
+ end
72
+
73
+ # 035 Halmstad
74
+ def test_halmstad
75
+ parse_test('+46355555555', '46', '35', '5555555')
76
+ end
77
+
78
+ # 036 Jönköping-Huskvarna
79
+ def test_jonkoping
80
+ parse_test('+46365555555', '46', '36', '5555555')
81
+ end
82
+
83
+ # 040 Malmö
84
+ def test_malmo
85
+ parse_test('+46405555555', '46', '40', '5555555')
86
+ end
87
+
88
+ # 042 Helsingborg-Höganäs
89
+ def test_helsingborg
90
+ parse_test('+46425555555', '46', '42', '5555555')
91
+ end
92
+
93
+ # 044 Kristianstad
94
+ def test_kristianstad
95
+ parse_test('+46445555555', '46', '44', '5555555')
96
+ end
97
+
98
+ # 046 Lund
99
+ def test_lund
100
+ parse_test('+46465555555', '46', '46', '5555555')
101
+ end
102
+
103
+ # 054 Karlstad
104
+ def test_karlstad
105
+ parse_test('+46545555555', '46', '54', '5555555')
106
+ end
107
+
108
+ # 060 Sundsvall-Timrå
109
+ def test_sundsvall
110
+ parse_test('+46605555555', '46', '60', '5555555')
111
+ end
112
+
113
+ # 063 Östersund
114
+ def test_ostersund
115
+ parse_test('+46635555555', '46', '63', '5555555', "Sweden", false)
116
+ end
117
+
118
+ # 070,
119
+ def test_mobile_70
120
+ parse_test('+46705555555', '46', '70', '5555555', "Sweden", true)
121
+ end
122
+
123
+ # 071 Telematics in Mobile Networks (used to be Premium rate numbers)
124
+ def test_telematics
125
+ parse_test('+46715555555', '46', '71', '5555555')
126
+ end
127
+
128
+ # 072,
129
+ def test_mobile_72
130
+ parse_test('+46725555555', '46', '72', '5555555')
131
+ end
132
+
133
+ # 073,
134
+ def test_mobile_73
135
+ parse_test('+46735555555', '46', '73', '5555555')
136
+ end
137
+
138
+ # 076 Mobile networks
139
+ def test_mobile_76
140
+ parse_test('+46765555555', '46', '76', '5555555')
141
+ end
142
+
143
+ # 090 Umeå
144
+ def test_umea
145
+ parse_test('+46905555555', '46', '90', '5555555')
146
+ end
147
+
148
+ # 099 Premium rate calls
149
+ def test_premium_99
150
+ parse_test('+46995555555', '46', '99', '5555555')
151
+ end
152
+
153
+ ## three digit codes
154
+
155
+ # 0120 Åtvidaberg
156
+ def test_atvidaberg
157
+ parse_test('+46120555555', '46', '120', '555555')
158
+ end
159
+ # 0121 Söderköping
160
+ # 0122 Finspång
161
+ # 0123 Valdemarsvik
162
+ # 0125 Vikbolandet
163
+ # 0140 Tranås
164
+ # 0141 Motala
165
+ # 0142 Mjölby-Skänninge-Boxholm
166
+ # 0143 Vadstena
167
+ # 0144 Ödeshög
168
+ # 0150 Katrineholm
169
+ # 0151 Vingåker
170
+ # 0152 Strängnäs
171
+ # 0155 Nyköping-Oxelösund
172
+ # 0156 Trosa-Vagnhärad
173
+ # 0157 Flen-Malmköping
174
+ # 0158 Gnesta
175
+ # 0159 Mariefred
176
+ # 0171 Enköping
177
+ def test_enkoping
178
+ parse_test('+461715555555', '46', '171', '5555555')
179
+ end
180
+ # 0173 Öregrund-Östhammar
181
+ # 0174 Alunda
182
+ # 0175 Hallstavik-Rimbo
183
+ # 0176 Norrtälje
184
+
185
+ # 0220 Hallstahammar-Surahammar
186
+ def test_hallstahammar
187
+ parse_test('+462205555555', '46', '220', '5555555')
188
+ end
189
+ # 0221 Köping
190
+ # 0222 Skinnskatteberg
191
+ # 0223 Fagersta-Norberg
192
+ # 0224 Sala-Heby
193
+ # 0225 Hedemora-Säter
194
+ # 0226 Avesta-Krylbo
195
+ # 0227 Kungsör
196
+ # 0240 Ludvika-Smedjebacken
197
+ # 0241 Gagnef-Floda
198
+ # 0243 Borlänge
199
+ # 0246 Svärdsjö-Enviken
200
+ # 0247 Leksand-Insjön
201
+ # 0248 Rättvik
202
+ def test_rattvik
203
+ parse_test('+462485555555', '46', '248', '5555555')
204
+ end
205
+ # 0250 Mora-Orsa
206
+ # 0251 Älvdalen
207
+ # 0253 Idre-Särna
208
+ # 0258 Furudal
209
+ # 0270 Söderhamn
210
+ # 0271 Alfta-Edsbyn
211
+ # 0278 Bollnäs
212
+ # 0280 Malung
213
+ # 0281 Vansbro
214
+ # 0290 Hofors-Storvik
215
+ # 0291 Hedesunda-Österfärnebo
216
+ # 0292 Tärnsjö-Östervåla
217
+ # 0293 Tierp-Söderfors
218
+ # 0294 Karlholmsbruk-Skärplinge
219
+ # 0295 Örbyhus-Dannemora
220
+ # 0297 Ockelbo-Hamrånge
221
+ def test_ockelbo
222
+ parse_test('+462975555555', '46', '297', '5555555')
223
+ end
224
+
225
+ # 0300 Kungsbacka
226
+ def test_kungsbacka
227
+ parse_test('+463005555555', '46', '300', '5555555')
228
+ end
229
+ # 0301 Hindås
230
+ # 0302 Lerum
231
+ # 0303 Kungälv
232
+ # 0304 Orust-Tjörn
233
+ # 0320 Kinna
234
+ # 0321 Ulricehamn
235
+ # 0322 Alingsås-Vårgårda
236
+ # 0325 Svenljunga-Tranemo
237
+ # 0340 Varberg
238
+ def test_varberg
239
+ parse_test('+463405555555', '46', '340', '5555555')
240
+ end
241
+ # 0345 Hyltebruk-Torup
242
+ # 0346 Falkenberg
243
+ # 0370 Värnamo
244
+ # 0371 Gislaved-Anderstorp
245
+ # 0372 Ljungby
246
+ # 0380 Nässjö
247
+ # 0381 Eksjö
248
+ # 0382 Sävsjö
249
+ # 0383 Vetlanda
250
+ # 0390 Gränna
251
+ # 0392 Mullsjö
252
+ # 0393 Vaggeryd
253
+
254
+ # 0410 Trelleborg
255
+ def test_trelleborg
256
+ parse_test('+464105555555', '46', '410', '5555555')
257
+ end
258
+ # 0411 Ystad
259
+ # 0413 Eslöv-Höör
260
+ # 0414 Simrishamn
261
+ # 0415 Hörby
262
+ # 0416 Sjöbo
263
+ # 0417 Tomelilla
264
+ # 0418 Landskrona-Svalöv
265
+ # 0430 Laholm
266
+ def test_lanholm
267
+ parse_test('+464305555555', '46', '430', '5555555')
268
+ end
269
+ # 0431 Ängelholm-Båstad
270
+ # 0433 Markaryd-Strömsnäsbruk
271
+ # 0435 Klippan-Perstorp
272
+ # 0451 Hässleholm
273
+ # 0454 Karlshamn-Olofström
274
+ # 0455 Karlskrona
275
+ # 0456 Sölvesborg-Bromölla
276
+ # 0457 Ronneby
277
+ # 0459 Ryd
278
+ # 0470 Växjö
279
+ def test_vaxjo
280
+ parse_test('+464705555555', '46', '470', '5555555')
281
+ end
282
+ # 0471 Emmaboda
283
+ # 0472 Alvesta-Rydaholm
284
+ # 0474 Åseda-Lenhovda
285
+ # 0476 Älmhult
286
+ # 0477 Tingsryd
287
+ # 0478 Lessebo
288
+ # 0479 Osby
289
+ # 0480 Kalmar
290
+ # 0481 Nybro
291
+ # 0485 Öland
292
+ # 0486 Torsås
293
+ # 0490 Västervik
294
+ # 0491 Oskarshamn-Högsby
295
+ # 0492 Vimmerby
296
+ # 0493 Gamleby
297
+ # 0494 Kisa
298
+ def test_kisa
299
+ parse_test('+464945555555', '46', '494', '5555555')
300
+ end
301
+ # 0495 Hultsfred-Virserum
302
+ # 0496 Mariannelund
303
+ # 0498 Gotland
304
+ # 0499 Mönsterås
305
+
306
+ # 0500 Skövde
307
+ def test_skovde
308
+ parse_test('+465005555555', '46', '500', '5555555')
309
+ end
310
+ # 0501 Mariestad
311
+ # 0502 Tidaholm
312
+ # 0503 Hjo
313
+ def test_hjo
314
+ parse_test('+465035555555', '46', '503', '5555555')
315
+ end
316
+ # 0504 Tibro
317
+ # 0505 Karlsborg
318
+ # 0506 Töreboda-Hova
319
+ # 0510 Lidköping
320
+ # 0511 Skara-Götene
321
+ # 0512 Vara-Nossebro
322
+ # 0513 Herrljunga
323
+ # 0514 Grästorp
324
+ # 0515 Falköping
325
+ # 0520 Trollhättan
326
+ # 0521 Vänersborg
327
+ # 0522 Uddevalla
328
+ # 0523 Lysekil
329
+ # 0524 Munkedal
330
+ # 0525 Grebbestad
331
+ # 0526 Strömstad
332
+ # 0528 Färgelanda
333
+ # 0530 Mellerud
334
+ # 0531 Bengtsfors
335
+ # 0532 Åmål
336
+ # 0533 Säffle
337
+ # 0534 Ed
338
+ # 0550 Kristinehamn
339
+ # 0551 Gullspång
340
+ # 0552 Deje
341
+ def test_deje
342
+ parse_test('+465525555555', '46', '552', '5555555')
343
+ end
344
+ # 0553 Molkom
345
+ # 0554 Kil
346
+ # 0555 Grums
347
+ # 0560 Torsby
348
+ # 0563 Hagfors-Munkfors
349
+ # 0564 Sysslebäck
350
+ # 0565 Sunne
351
+ # 0570 Arvika
352
+ # 0571 Charlottenberg-Åmotfors
353
+ # 0573 Årjäng
354
+ # 0580 Kopparberg
355
+ # 0581 Lindesberg
356
+ # 0582 Hallsberg-Pålsboda
357
+ # 0583 Askersund
358
+ # 0584 Laxå
359
+ # 0585 Fjugesta-Svartå
360
+ # 0586 Karlskoga-Degerfors
361
+ # 0587 Nora
362
+ def test_nora
363
+ parse_test('+465875555555', '46', '587', '5555555')
364
+ end
365
+ # 0589 Arboga
366
+ # 0590 Filipstad
367
+ # 0591 Hällefors-Grythyttan
368
+
369
+ # 0611 Härnösand
370
+ def test_harnosand
371
+ parse_test('+466115555555', '46', '611', '5555555')
372
+ end
373
+ # 0612 Kramfors
374
+ # 0613 Ullånger
375
+ # 0620 Sollefteå
376
+ # 0621 Junsele
377
+ # 0622 Näsåker
378
+ # 0623 Ramsele
379
+ # 0624 Backe
380
+ # 0640 Krokom
381
+ # 0642 Lit
382
+ # 0643 Hallen-Oviken
383
+ # 0644 Hammerdal
384
+ # 0645 Föllinge
385
+ # 0647 Åre-Järpen
386
+ # 0650 Hudiksvall
387
+ # 0651 Ljusdal
388
+ # 0652 Bergsjö
389
+ # 0653 Delsbo
390
+ # 0657 Los
391
+ # 0660 Örnsköldsvik
392
+ # 0661 Bredbyn
393
+ # 0662 Björna
394
+ # 0663 Husum
395
+ def test_husum
396
+ parse_test('+466635555555', '46', '663', '5555555')
397
+ end
398
+ # 0670 Strömsund
399
+ # 0671 Hoting
400
+ # 0672 Gäddede
401
+ # 0680 Sveg
402
+ # 0682 Rätan
403
+ # 0684 Hede-Funäsdalen
404
+ # 0687 Svenstavik
405
+ # 0690 Ånge
406
+ # 0691 Torpshammar
407
+ # 0692 Liden
408
+ # 0693 Bräcke-Gällö
409
+ # 0695 Stugun
410
+ # 0696 Hammarstrand
411
+
412
+ # 07x(x) various non-geographical area codes
413
+ # ambiguous!
414
+
415
+ # 074(x) Pagers
416
+ def test_pagers
417
+ parse_test('+467405555555', '46', '740', '5555555')
418
+ end
419
+
420
+ # 0900 Premium rate calls
421
+ def test_premium_900
422
+ parse_test('+469005555555', '46', '900', '5555555')
423
+ end
424
+ # 0910 Skellefteå
425
+ # 0911 Piteå
426
+ # 0912 Byske
427
+ # 0913 Lövånger
428
+ # 0914 Burträsk
429
+ # 0915 Bastuträsk
430
+ # 0916 Jörn
431
+ def test_jorn
432
+ parse_test('+469165555555', '46', '916', '5555555')
433
+ end
434
+ # 0918 Norsjö
435
+ # 0920 Luleå
436
+ # 0921 Boden
437
+ # 0922 Haparanda
438
+ # 0923 Kalix
439
+ # 0924 Råneå
440
+ # 0925 Lakaträsk
441
+ # 0926 Överkalix
442
+ # 0927 Övertorneå
443
+ # 0928 Harads
444
+ # 0929 Älvsbyn
445
+ # 0930 Nordmaling
446
+ # 0932 Bjurholm
447
+ # 0933 Vindeln
448
+ # 0934 Robertsfors
449
+ # 0935 Vännäs
450
+ def test_vannas
451
+ parse_test('+469355555555', '46', '935', '5555555')
452
+ end
453
+ # 0939 Premium rate calls
454
+ # 0940 Vilhelmina
455
+ # 0941 Åsele
456
+ # 0942 Dorotea
457
+ # 0943 Fredrika
458
+ # 0944 Premium rate calls
459
+ # 0950 Lycksele
460
+ # 0951 Storuman
461
+ # 0952 Sorsele
462
+ # 0953 Malå
463
+ # 0954 Tärnaby
464
+ # 0960 Arvidsjaur
465
+ # 0961 Arjeplog
466
+ # 0970 Gällivare
467
+ # 0971 Jokkmokk
468
+ # 0973 Porjus
469
+ # 0975 Hakkas
470
+ # 0976 Vuollerim
471
+ # 0977 Korpilombolo
472
+ # 0978 Pajala
473
+ # 0980 Kiruna
474
+ # 0981 Vittangi
475
+ def test_vittangi
476
+ parse_test('+469815555555', '46', '981', '5555555')
477
+ end
478
+ end