-
Notifications
You must be signed in to change notification settings - Fork 35
/
fuzz.js
74 lines (65 loc) · 1.77 KB
/
fuzz.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
load("PhoneNumberMetadata.js");
load("PhoneNumberNormalizer.js");
load("PhoneNumber.js");
let gCountryList;
function TestProperties(dial, currentRegion) {
print("test: " + dial + ", " + currentRegion);
var result = PhoneNumber.Parse(dial, currentRegion);
if (result) {
var tmp = result.internationalFormat;
tmp = result.internationalNumber;
tmp = result.nationalNumber;
tmp = result.nationalFormat;
} else {
}
}
function makeid(maxSize)
{
var text = "";
var possible = "0123456789";
var length = Math.floor(Math.random() * maxSize);
for (var i=0; i < length; i++ )
text += (possible.charAt(Math.floor(Math.random() * possible.length)));
return text;
}
function getRandomCC() {
if (gCountryList) {
return gCountryList[Math.floor(Math.random() * gCountryList.length)];
}
gCountryList = [];
for (let id in PHONE_NUMBER_META_DATA) {
let obj = PHONE_NUMBER_META_DATA[id];
if (Array.isArray(obj)) {
for (let i = 0; i < obj.length; i++) {
let cc = obj[i].substring(2,4);
if (cc != "00")
gCountryList.push(cc);
}
} else {
let cc = obj.substring(2,4);
if (cc != "00")
gCountryList.push(cc);
}
}
return gCountryList[Math.floor(Math.random() * gCountryList.length)];
}
for (var i = 0; i < 100000; i++) {
let dial = makeid(15);
if (i % 3 == 0) {
let x = Math.floor(Math.random() * 3);
switch (x) {
case 0:
dial = ("+" + dial);
break;
case 1:
dial = ("+0" + dial);
break;
case 2:
dial = ("0" + dial);
break;
}
}
TestProperties(dial, getRandomCC());
}