Nipodemos

num and string extensions tests done

@@ -59,9 +59,9 @@ extension GetStringUtils on String { @@ -59,9 +59,9 @@ extension GetStringUtils on String {
59 59
60 bool get isCurrency => GetUtils.isCurrency(this); 60 bool get isCurrency => GetUtils.isCurrency(this);
61 61
62 - bool isCpf(String s) => GetUtils.isCpf(this); 62 + bool get isCpf => GetUtils.isCpf(this);
63 63
64 - bool isCnpj(String s) => GetUtils.isCnpj(this); 64 + bool get isCnpj => GetUtils.isCnpj(this);
65 65
66 bool isCaseInsensitiveContains(String b) => 66 bool isCaseInsensitiveContains(String b) =>
67 GetUtils.isCaseInsensitiveContains(this, b); 67 GetUtils.isCaseInsensitiveContains(this, b);
@@ -69,15 +69,14 @@ extension GetStringUtils on String { @@ -69,15 +69,14 @@ extension GetStringUtils on String {
69 bool isCaseInsensitiveContainsAny(String b) => 69 bool isCaseInsensitiveContainsAny(String b) =>
70 GetUtils.isCaseInsensitiveContainsAny(this, b); 70 GetUtils.isCaseInsensitiveContainsAny(this, b);
71 71
72 - String capitalize(String s, {bool firstOnly = false}) =>  
73 - GetUtils.capitalize(this, firstOnly: firstOnly); 72 + String get capitalize => GetUtils.capitalize(this);
74 73
75 - String capitalizeFirst(String s) => GetUtils.capitalizeFirst(this); 74 + String get capitalizeFirst => GetUtils.capitalizeFirst(this);
76 75
77 - String removeAllWhitespace(String s) => GetUtils.removeAllWhitespace(this); 76 + String get removeAllWhitespace => GetUtils.removeAllWhitespace(this);
78 77
79 - String camelCase(String s) => GetUtils.camelCase(this); 78 + String get camelCase => GetUtils.camelCase(this);
80 79
81 - String numericOnly(String s, {bool firstWordOnly = false}) => 80 + String numericOnly({bool firstWordOnly = false}) =>
82 GetUtils.numericOnly(this, firstWordOnly: firstWordOnly); 81 GetUtils.numericOnly(this, firstWordOnly: firstWordOnly);
83 } 82 }
@@ -164,7 +164,7 @@ class GetUtils { @@ -164,7 +164,7 @@ class GetUtils {
164 r'^(?!0{3}|6{3}|9[0-9]{2})[0-9]{3}-?(?!0{2})[0-9]{2}-?(?!0{4})[0-9]{4}$'); 164 r'^(?!0{3}|6{3}|9[0-9]{2})[0-9]{3}-?(?!0{2})[0-9]{2}-?(?!0{4})[0-9]{4}$');
165 165
166 /// Checks if string is binary. 166 /// Checks if string is binary.
167 - static bool isBinary(String s) => hasMatch(s, r'^[0-1]*$'); 167 + static bool isBinary(String s) => hasMatch(s, r'^[0-1]+$');
168 168
169 /// Checks if string is IPv4. 169 /// Checks if string is IPv4.
170 static bool isIPv4(String s) => 170 static bool isIPv4(String s) =>
@@ -181,9 +181,13 @@ class GetUtils { @@ -181,9 +181,13 @@ class GetUtils {
181 181
182 /// Checks if string is Palindrom. 182 /// Checks if string is Palindrom.
183 static bool isPalindrom(String s) { 183 static bool isPalindrom(String s) {
  184 + final cleanString = s
  185 + .toLowerCase()
  186 + .replaceAll(RegExp(r"\s+"), '')
  187 + .replaceAll(RegExp(r"[^0-9a-zA-Z]+"), "");
184 var isPalindrom = true; 188 var isPalindrom = true;
185 - for (var i = 0; i < s.length; i++) {  
186 - if (s[i] != s[s.length - i - 1]) { 189 + for (var i = 0; i < cleanString.length; i++) {
  190 + if (cleanString[i] != cleanString[cleanString.length - i - 1]) {
187 isPalindrom = false; 191 isPalindrom = false;
188 } 192 }
189 } 193 }
@@ -221,7 +225,7 @@ class GetUtils { @@ -221,7 +225,7 @@ class GetUtils {
221 225
222 /// Checks if string is Currency. 226 /// Checks if string is Currency.
223 static bool isCurrency(String s) => hasMatch(s, 227 static bool isCurrency(String s) => hasMatch(s,
224 - r'^(S?\$|\₩|Rp|\¥|\€|\₹|\₽|fr|R$|R)?[ ]?[-]?([0-9]{1,3}[,.]([0-9]{3}[,.])*[0-9]{3}|[0-9]+)([,.][0-9]{1,2})?( ?(USD?|AUD|NZD|CAD|CHF|GBP|CNY|EUR|JPY|IDR|MXN|NOK|KRW|TRY|INR|RUB|BRL|ZAR|SGD|MYR))?$'); 228 + r'^(S?\$|\₩|Rp|\¥|\€|\₹|\₽|fr|R\$|R)?[ ]?[-]?([0-9]{1,3}[,.]([0-9]{3}[,.])*[0-9]{3}|[0-9]+)([,.][0-9]{1,2})?( ?(USD?|AUD|NZD|CAD|CHF|GBP|CNY|EUR|JPY|IDR|MXN|NOK|KRW|TRY|INR|RUB|BRL|ZAR|SGD|MYR))?$');
225 229
226 /// Checks if length of data is LOWER than maxLength. 230 /// Checks if length of data is LOWER than maxLength.
227 static bool isLengthLowerThan(dynamic s, int maxLength) { 231 static bool isLengthLowerThan(dynamic s, int maxLength) {
@@ -436,22 +440,6 @@ class GetUtils { @@ -436,22 +440,6 @@ class GetUtils {
436 return true; 440 return true;
437 } 441 }
438 442
439 - /// Capitalize each word inside string  
440 - /// Example: your name => Your Name, your name => Your name  
441 - ///  
442 - /// If First Only is `true`, the only letter get uppercase is the first letter  
443 - static String capitalize(String s, {bool firstOnly = false}) {  
444 - if (isNullOrBlank(s)) return null;  
445 - if (firstOnly) return capitalizeFirst(s);  
446 -  
447 - var lst = s.split(' ');  
448 - var newStr = '';  
449 - for (var s in lst) {  
450 - newStr += capitalizeFirst(s);  
451 - }  
452 - return newStr;  
453 - }  
454 -  
455 /// Uppercase first letter inside string and let the others lowercase 443 /// Uppercase first letter inside string and let the others lowercase
456 /// Example: your name => Your name 444 /// Example: your name => Your name
457 static String capitalizeFirst(String s) { 445 static String capitalizeFirst(String s) {
@@ -459,6 +447,20 @@ class GetUtils { @@ -459,6 +447,20 @@ class GetUtils {
459 return s[0].toUpperCase() + s.substring(1).toLowerCase(); 447 return s[0].toUpperCase() + s.substring(1).toLowerCase();
460 } 448 }
461 449
  450 + /// Capitalize each word inside string
  451 + /// Example: your name => Your Name, your name => Your name
  452 + static String capitalize(String s) {
  453 + if (isNullOrBlank(s)) return null;
  454 +
  455 + var separatedWords = s.split(' ');
  456 + var result = '';
  457 + for (var word in separatedWords) {
  458 + result += capitalizeFirst(word);
  459 + result += ' ';
  460 + }
  461 + return result.trim();
  462 + }
  463 +
462 /// Remove all whitespace inside string 464 /// Remove all whitespace inside string
463 /// Example: your name => yourname 465 /// Example: your name => yourname
464 static String removeAllWhitespace(String s) { 466 static String removeAllWhitespace(String s) {
@@ -470,7 +472,13 @@ class GetUtils { @@ -470,7 +472,13 @@ class GetUtils {
470 /// Example: your name => yourName 472 /// Example: your name => yourName
471 static String camelCase(String s) { 473 static String camelCase(String s) {
472 if (isNullOrBlank(s)) return null; 474 if (isNullOrBlank(s)) return null;
473 - return s[0].toLowerCase() + removeAllWhitespace(capitalize(s)).substring(1); 475 + var separatedWords = s.split(' ');
  476 + var newString = '';
  477 + for (final word in separatedWords) {
  478 + newString += word[0].toUpperCase() + word.substring(1).toLowerCase();
  479 + }
  480 +
  481 + return newString[0].toLowerCase() + newString.substring(1);
474 } 482 }
475 483
476 /// Extract numeric value of string 484 /// Extract numeric value of string
@@ -69,8 +69,7 @@ extension GetStringUtils on String { @@ -69,8 +69,7 @@ extension GetStringUtils on String {
69 bool isCaseInsensitiveContainsAny(String b) => 69 bool isCaseInsensitiveContainsAny(String b) =>
70 GetUtils.isCaseInsensitiveContainsAny(this, b); 70 GetUtils.isCaseInsensitiveContainsAny(this, b);
71 71
72 - String capitalize(String s, {bool firstOnly = false}) =>  
73 - GetUtils.capitalize(this, firstOnly: firstOnly); 72 + String capitalize(String s) => GetUtils.capitalize(this);
74 73
75 String capitalizeFirst(String s) => GetUtils.capitalizeFirst(this); 74 String capitalizeFirst(String s) => GetUtils.capitalizeFirst(this);
76 75
1 import 'package:flutter_test/flutter_test.dart'; 1 import 'package:flutter_test/flutter_test.dart';
2 2
3 void main() { 3 void main() {
4 - test('', () {}); 4 + group('Test group for extension: isNullOrBlank', () {
  5 + dynamic testString;
  6 + test('String extension: isNullOrBlank', () {
  7 + expect(testString.isNullOrBlank, equals(true));
  8 + });
  9 + test('String extension: isNullOrBlank', () {
  10 + testString = 'Not null anymore';
  11 + expect(testString.isNullOrBlank, equals(false));
  12 + });
  13 + test('String extension: isNullOrBlank', () {
  14 + testString = '';
  15 + expect(testString.isNullOrBlank, equals(true));
  16 + });
  17 + });
5 } 18 }
@@ -2,28 +2,13 @@ import 'package:flutter_test/flutter_test.dart'; @@ -2,28 +2,13 @@ import 'package:flutter_test/flutter_test.dart';
2 import 'package:get/utils.dart'; 2 import 'package:get/utils.dart';
3 3
4 void main() { 4 void main() {
5 - group('Test group for extension: isNullOrBlank', () {  
6 - String testString;  
7 - test('String extension: isNullOrBlank', () {  
8 - expect(testString.isNullOrBlank, equals(true));  
9 - });  
10 - test('String extension: isNullOrBlank', () {  
11 - testString = 'Not null anymore';  
12 - expect(testString.isNullOrBlank, equals(false));  
13 - });  
14 - test('String extension: isNullOrBlank', () {  
15 - testString = '';  
16 - expect(testString.isNullOrBlank, equals(true));  
17 - });  
18 - });  
19 -  
20 group('String extensions', () { 5 group('String extensions', () {
21 - var text = "oi";  
22 - var digit = "5";  
23 - var specialCaracters = "#\$!%@";  
24 - var alphaNumeric = "123asd";  
25 - var numbers = "123";  
26 - var letters = "foo"; 6 + final text = "oi";
  7 + final digit = "5";
  8 + final specialCaracters = "#\$!%@";
  9 + final alphaNumeric = "123asd";
  10 + final numbers = "123";
  11 + final letters = "foo";
27 String notInitializedVar; 12 String notInitializedVar;
28 13
29 test('var.isNum', () { 14 test('var.isNum', () {
@@ -45,27 +30,27 @@ void main() { @@ -45,27 +30,27 @@ void main() {
45 }); 30 });
46 31
47 test('var.isBool', () { 32 test('var.isBool', () {
48 - var trueString = 'true'; 33 + final trueString = 'true';
49 expect(notInitializedVar.isBool, false); 34 expect(notInitializedVar.isBool, false);
50 expect(letters.isBool, false); 35 expect(letters.isBool, false);
51 expect(trueString.isBool, true); 36 expect(trueString.isBool, true);
52 }); 37 });
53 38
54 test('var.isVectorFileName', () { 39 test('var.isVectorFileName', () {
55 - var path = "logo.svg";  
56 - var fullPath = "C:/Users/Getx/Documents/logo.svg"; 40 + final path = "logo.svg";
  41 + final fullPath = "C:/Users/Getx/Documents/logo.svg";
57 expect(path.isVectorFileName, true); 42 expect(path.isVectorFileName, true);
58 expect(fullPath.isVectorFileName, true); 43 expect(fullPath.isVectorFileName, true);
59 expect(alphaNumeric.isVectorFileName, false); 44 expect(alphaNumeric.isVectorFileName, false);
60 }); 45 });
61 46
62 test('var.isImageFileName', () { 47 test('var.isImageFileName', () {
63 - var jpgPath = "logo.jpg";  
64 - var jpegPath = "logo.jpeg";  
65 - var pngPath = "logo.png";  
66 - var gifPath = "logo.gif";  
67 - var bmpPath = "logo.bmp";  
68 - var svgPath = "logo.svg"; 48 + final jpgPath = "logo.jpg";
  49 + final jpegPath = "logo.jpeg";
  50 + final pngPath = "logo.png";
  51 + final gifPath = "logo.gif";
  52 + final bmpPath = "logo.bmp";
  53 + final svgPath = "logo.svg";
69 54
70 expect(jpgPath.isImageFileName, true); 55 expect(jpgPath.isImageFileName, true);
71 expect(jpegPath.isImageFileName, true); 56 expect(jpegPath.isImageFileName, true);
@@ -76,12 +61,12 @@ void main() { @@ -76,12 +61,12 @@ void main() {
76 }); 61 });
77 62
78 test('var.isAudioFileName', () { 63 test('var.isAudioFileName', () {
79 - var mp3Path = "logo.mp3";  
80 - var wavPath = "logo.wav";  
81 - var wmaPath = "logo.wma";  
82 - var amrPath = "logo.amr";  
83 - var oggPath = "logo.ogg";  
84 - var svgPath = "logo.svg"; 64 + final mp3Path = "logo.mp3";
  65 + final wavPath = "logo.wav";
  66 + final wmaPath = "logo.wma";
  67 + final amrPath = "logo.amr";
  68 + final oggPath = "logo.ogg";
  69 + final svgPath = "logo.svg";
85 70
86 expect(mp3Path.isAudioFileName, true); 71 expect(mp3Path.isAudioFileName, true);
87 expect(wavPath.isAudioFileName, true); 72 expect(wavPath.isAudioFileName, true);
@@ -92,14 +77,14 @@ void main() { @@ -92,14 +77,14 @@ void main() {
92 }); 77 });
93 78
94 test('var.isVideoFileName', () { 79 test('var.isVideoFileName', () {
95 - var mp4Path = "logo.mp4";  
96 - var aviPath = "logo.avi";  
97 - var wmvPath = "logo.wmv";  
98 - var rmvbPath = "logo.rmvb";  
99 - var mpgPath = "logo.mpg";  
100 - var mpegPath = "logo.mpeg";  
101 - var threegpPath = "logo.3gp";  
102 - var svgPath = "logo.svg"; 80 + final mp4Path = "logo.mp4";
  81 + final aviPath = "logo.avi";
  82 + final wmvPath = "logo.wmv";
  83 + final rmvbPath = "logo.rmvb";
  84 + final mpgPath = "logo.mpg";
  85 + final mpegPath = "logo.mpeg";
  86 + final threegpPath = "logo.3gp";
  87 + final svgPath = "logo.svg";
103 88
104 expect(mp4Path.isVideoFileName, true); 89 expect(mp4Path.isVideoFileName, true);
105 expect(aviPath.isVideoFileName, true); 90 expect(aviPath.isVideoFileName, true);
@@ -110,5 +95,621 @@ void main() { @@ -110,5 +95,621 @@ void main() {
110 expect(threegpPath.isVideoFileName, true); 95 expect(threegpPath.isVideoFileName, true);
111 expect(svgPath.isAudioFileName, false); 96 expect(svgPath.isAudioFileName, false);
112 }); 97 });
  98 +
  99 + test('var.isTxtFileName', () {
  100 + const txtPath = 'file.txt';
  101 + expect(txtPath.isTxtFileName, true);
  102 + expect(alphaNumeric.isTxtFileName, false);
  103 + });
  104 +
  105 + test('var.isDocumentFileName', () {
  106 + final docPath = "file.doc";
  107 + final docxPath = "file.docx";
  108 +
  109 + expect(docPath.isDocumentFileName, true);
  110 + expect(docxPath.isDocumentFileName, true);
  111 + expect(alphaNumeric.isDocumentFileName, false);
  112 + });
  113 +
  114 + test('var.isExcelFileName', () {
  115 + final xlsPath = "file.xls";
  116 + final xlsxPath = "file.xlsx";
  117 +
  118 + expect(xlsPath.isExcelFileName, true);
  119 + expect(xlsxPath.isExcelFileName, true);
  120 + expect(alphaNumeric.isExcelFileName, false);
  121 + });
  122 +
  123 + test('var.isPPTFileName', () {
  124 + final pptPath = "file.ppt";
  125 + final pptxPath = "file.pptx";
  126 +
  127 + expect(pptPath.isPPTFileName, true);
  128 + expect(pptxPath.isPPTFileName, true);
  129 + expect(alphaNumeric.isPPTFileName, false);
  130 + });
  131 +
  132 + test('var.isAPKFileName', () {
  133 + final apkPath = "file.apk";
  134 +
  135 + expect(apkPath.isAPKFileName, true);
  136 + expect(alphaNumeric.isAPKFileName, false);
  137 + });
  138 +
  139 + test('var.isPDFFileName', () {
  140 + final pdfPath = "file.pdf";
  141 +
  142 + expect(pdfPath.isPDFFileName, true);
  143 + expect(alphaNumeric.isPDFFileName, false);
  144 + });
  145 + test('var.isHTMLFileName', () {
  146 + final htmlPath = "file.html";
  147 +
  148 + expect(htmlPath.isHTMLFileName, true);
  149 + expect(alphaNumeric.isHTMLFileName, false);
  150 + });
  151 + test('var.isURL', () {
  152 + // Url's generated in https://www.randomlists.com/urls
  153 + final urls = [
  154 + 'http://www.example.com/aunt/babies.aspx#act',
  155 + 'http://adjustment.example.com/bedroom/animal.htm',
  156 + 'http://blade.example.com/arch/basketball',
  157 + 'https://www.example.com/air/advice.php',
  158 + 'http://www.example.com/balance/arch.html?blow=aftermath&bait=bath',
  159 + 'http://authority.example.com/',
  160 + 'http://example.com/advice.html',
  161 + 'https://www.example.com/',
  162 + 'https://www.example.com/bee?act=art&bells=board',
  163 + 'http://example.org/',
  164 + 'https://www.example.com/',
  165 + 'https://example.com/bed',
  166 + 'https://www.example.edu/acoustics',
  167 + 'https://www.example.com/bells',
  168 + 'http://board.example.com/',
  169 + 'http://book.example.com/afterthought?advertisement=ball&birth=argument',
  170 + 'http://birds.example.org/ball.aspx?apparatus=border&brother=aftermath',
  171 + 'https://www.example.org/books/book?bedroom=birds',
  172 + 'http://advice.example.com/',
  173 + 'http://example.com/',
  174 + 'http://example.com/bedroom/alarm',
  175 + 'https://example.com/advice/approval',
  176 + 'http://anger.example.net/?breath=brother&air=bell#ball',
  177 + 'http://appliance.example.com/bee/badge',
  178 + 'http://www.example.org/berry.aspx',
  179 + 'http://example.org/',
  180 + ];
  181 +
  182 + for (final url in urls) {
  183 + expect(url.isURL, true);
  184 + }
  185 + expect(alphaNumeric.isURL, false);
  186 + });
  187 + test('var.isEmail', () {
  188 + final emails = [
  189 + 'hellfire@comcast.net',
  190 + 'hllam@icloud.com',
  191 + 'tskirvin@live.com',
  192 + 'choset@comcast.net',
  193 + 'parksh@live.com',
  194 + 'kassiesa@yahoo.com',
  195 + 'kramulous@comcast.net',
  196 + 'froodian@me.com',
  197 + 'shawnce@yahoo.ca',
  198 + 'cgreuter@gmail.com',
  199 + 'aprakash@verizon.net',
  200 + 'dhrakar@gmail.com',
  201 + 'wmszeliga@yahoo.ca',
  202 + 'bmorrow@icloud.com',
  203 + 'seurat@comcast.net',
  204 + 'dialworld@yahoo.ca',
  205 + 'johndo@yahoo.ca',
  206 + 'empathy@yahoo.com.pt',
  207 + 'openldap@verizon.net',
  208 + 'elflord@outlook.com',
  209 + 'kaiser@me.com',
  210 + 'carcus@att.net',
  211 + 'garland@hotmail.com',
  212 + 'clkao@yahoo.ca',
  213 + 'daveed@mac.com',
  214 + 'parasite@icloud.com',
  215 + 'drolsky@aol.com',
  216 + 'reziac@outlook.com',
  217 + 'storerm@yahoo.ca',
  218 + 'johnbob@hotmail.com.br',
  219 + ];
  220 +
  221 + for (final email in emails) {
  222 + expect(email.isEmail, true);
  223 + }
  224 + expect(alphaNumeric.isEmail, false);
  225 + });
  226 + test('var.isPhoneNumber', () {
  227 + final phoneNumbers = [
  228 + '+1202-555-0145',
  229 + '+1202-555-0139',
  230 + '+1202-555-0101',
  231 + '+1202-555-0136',
  232 + '+1202-555-0190',
  233 + '+1202-555-0156',
  234 + '(738) 952-5253',
  235 + '(861) 965-1597',
  236 + '(732) 372-9760',
  237 + '(532) 766-4719',
  238 + '(987) 472-7813',
  239 + '(455) 443-8171',
  240 + '(915) 685-8658',
  241 + '(572) 207-1898',
  242 +
  243 + // TODO those are failing, but they shouldn't
  244 + // '(81) 6 2499-9538',
  245 + // '(31) 32304-4263',
  246 + // '(64) 25242-6375',
  247 + // '(41) 19308-7925',
  248 + // '(67) 61684-0395',
  249 + // '(60) 54706-3569',
  250 + '(31) 33110055',
  251 + '(11) 3344-5599',
  252 + '(31) 977447788',
  253 + '(31) 66557744',
  254 + '(21) 946576541',
  255 + '(11) 3432-3333',
  256 + '02131973585858'
  257 + ];
  258 +
  259 + for (final phone in phoneNumbers) {
  260 + print('testing $phone');
  261 + expect(phone.isPhoneNumber, true);
  262 + }
  263 +
  264 + final bigRandomNumber = '168468468465241327987624987327987';
  265 + expect(bigRandomNumber.isPhoneNumber, false);
  266 +
  267 + expect(alphaNumeric.isPhoneNumber, false);
  268 + });
  269 + test('var.isDateTime', () {
  270 + final dateTimes = [
  271 + '2003-07-05 05:51:47.000Z',
  272 + '1991-05-11 11:57:30.000Z',
  273 + '2002-01-04 10:00:41.000Z',
  274 + '1995-11-04 19:43:25.000Z',
  275 + '2006-07-12 20:06:46.000Z',
  276 + '2000-08-10 00:06:23.000Z',
  277 + '1998-07-31 10:56:50.000Z',
  278 + '1995-04-27 11:49:34.000Z',
  279 + '1998-07-26 15:43:11.000Z',
  280 + '1999-02-04 10:03:01.000Z',
  281 + '1998-05-02 12:17:55.000Z',
  282 + '2013-05-26 10:47:22.000Z',
  283 + '1991-07-07 20:25:42.000Z',
  284 + '2018-11-03 09:27:38.000Z',
  285 + '1992-12-22 08:20:26.000Z',
  286 + '1997-07-01 23:11:59.000Z',
  287 + '2012-04-13 16:00:04.000Z',
  288 + '1997-01-06 18:37:51.000Z',
  289 + '2008-08-23 11:11:29.000Z',
  290 + '1996-02-06 03:46:43.000Z',
  291 + '2016-01-03 10:57:15.000Z',
  292 + '2014-04-16 17:20:50.000Z',
  293 + '1994-07-13 03:55:16.000Z',
  294 + '2004-11-15 03:45:11.000Z',
  295 + '2007-12-18 18:21:21.000Z',
  296 + '1995-01-31 03:55:44.000Z',
  297 + '2013-08-09 04:48:37.000Z',
  298 + '2001-09-07 17:13:55.000Z',
  299 + '1993-06-18 13:21:21.000Z',
  300 + '1991-02-06 03:05:47.000Z',
  301 + '2000-09-22 18:48:55.000Z',
  302 + '2000-06-01 02:13:57.000Z',
  303 + '1991-08-07 21:08:35.000Z',
  304 + '1998-08-15 07:27:12.000Z',
  305 + '2002-07-03 10:34:25.000Z',
  306 + '2013-10-05 00:37:45.000Z',
  307 + '2012-09-10 20:07:21.000Z',
  308 + '2017-06-18 14:38:06.000Z',
  309 + '2000-03-09 11:27:49.000Z',
  310 + '2016-01-16 22:01:20.000Z',
  311 + ];
  312 +
  313 + for (final dateTime in dateTimes) {
  314 + // print('testing $dateTime');
  315 + expect(dateTime.isDateTime, true);
  316 + }
  317 + expect(alphaNumeric.isDateTime, false);
  318 + });
  319 + test('var.isMD5', () {
  320 + final md5s = [
  321 + '176cfa006065a2a2bd8d3f1f83531b64',
  322 + '713fca6d088132e863497a79d1bd9572',
  323 + '7decc2fb2aca5cbd8a2cae5de1b50edb',
  324 + '85ed9bc4e4a8ae65add67886f5dfe02f',
  325 + 'e4f0097f84a11f0298c83ecf6aa0fec3',
  326 + '70a2712b47127b431d7119b3a511b145',
  327 + 'dd54069e3f97787e79592f6e3a307e93',
  328 + '5b64677b69da7370ee69523281ce935c',
  329 + '6150ce23f4b071e1cde49021b57c5a17',
  330 + '2781566b09a84a695297482cdcb1ffd0',
  331 + '54fe4ce16862aac01768b5831390d557',
  332 + '2747268afaa9898a320b8cc5580f143e',
  333 + 'ce3c2d105fb2740c5bf59347b47603a8',
  334 + 'cccef3bbc8cd2530c6de78af586ebcee',
  335 + '502115b10c767f50ab55270be095512e',
  336 + 'b084ea385e849eaedf4fefaf6dd5f1a9',
  337 + '1f167339977225fe63a86388083fc64f',
  338 + '6abd5f472dba5e4688ad6dd14f975870',
  339 + '7e7f9ef53fb6e3ce2a4fb56665548eb8',
  340 + 'de134fce82421dd2b3fab751fbfa190d',
  341 + 'b0d8492572a52d1f2360535612c5dc82',
  342 + ];
  343 +
  344 + for (final md5 in md5s) {
  345 + expect(md5.isMD5, true);
  346 + }
  347 +
  348 + expect(alphaNumeric.isMD5, false);
  349 + });
  350 + test('var.isSHA1', () {
  351 + final sha1s = [
  352 + '1A310CF5DC8CE513586F74EE19CE90BD4BCC5AED',
  353 + 'B458B077B5075C316CFD03619D627F529A0555BF',
  354 + '902C6A2850B4348BE445D637689CCAE5C5EF3552',
  355 + '8DC86C0DD0FD2960D62573AB142F90572A7421D5',
  356 + '7E18C8EA5F05BB2F385A9E34657B8D439A83BF82',
  357 + '3EC857A133E801C0B3198371C17C1A3A3D73DFE8',
  358 + 'E32590E41805BEFD524205DAE0A56F429DCCC4E7',
  359 + '943A9164A126457203680B49F0309B5F15F0117E',
  360 + 'C5E1442484AF49A92E1CC51F95AE4E8305F49DB6',
  361 + 'B0C3B071F8ADBEE2222AA07ECFF51C3C040AA0A0',
  362 + '722ED6929057BF801F29590C423A40F4EF8C710E',
  363 + 'F484FA4DC5EC1E063F0752112D9BF3B9763D6E41',
  364 + '2A87522644011223A27FD62C87FA926A1838F271',
  365 + ];
  366 +
  367 + for (final sha1 in sha1s) {
  368 + expect(sha1.isSHA1, true);
  369 + }
  370 +
  371 + expect(alphaNumeric.isSHA1, false);
  372 + });
  373 + test('var.isSHA256', () {
  374 + final sha256s = [
  375 + 'FC694FFE78167EAE21EA4EBF072D8AB6ECF847162D1F65600BF019BA9805DB2D',
  376 + '3B64F1C349B548E72688A8EEFFA2F418A62BA2E22CF5BD954B4B1912C963D7FA',
  377 + 'EF69D763148B8A222980BD164943F754937DF12771083889DDB69C18245C2904',
  378 + '9896D3134156E546FFC003C2C9CFED88D46C2BC214B39CF21192EAAF875A7C0A',
  379 + '2C70E9735D7DAB56427BAA09E6C63912BEAD9C7938F6B16C4954B78F46D1C3CF',
  380 + '423E095C8074BC1C440D874D999C18025445CD39211D98362E827E55863DD0B2',
  381 + '4FCDB44D5521663F713A5821DE9401D64D44050C2AF62EBA758B1D128AC4C279',
  382 + 'BD91C9BBC044C94C283D0DF3AA1E8CDBF1BF35BF325E8196BA15FCA5238A3A40',
  383 + '7B9434447F3B1236221D40CB707D1909886CC9E8CA25EB18DCCFDC70F0A3AE9F',
  384 + 'FBD3A0B1C5F9906EF3BFB5EDD846F77BA252070E036EC1F4F57BDD912F02987D',
  385 + 'B8369EE116ADE797285DC973DDAA69433F255DC0AEEC7936378D4D08B2A7FDD2',
  386 + '6B6FE6891A5DFCCF2900A2A1F513196827AF5A95AB2DE1590B878BEFCCF12603',
  387 + 'F2CB3614CD070450912EBEC399C63527D2A839C4E5BB2FE281BA1C5D5EA64257',
  388 + '822805E8FA05909AD7D3D6DBFBB1AE61D7A3C70209DB2A37C415BD5E11764866',
  389 + '40DAC792B52101BB1506AD880F0378EFACF46B019427A3D0E01DE2B09B06B6ED',
  390 + 'E765A129579AF2F31C681973844490F8EA146DA8ADC07671F9FB71F0FE10E296',
  391 + '2B5B6DC7EF398D1420D23327295BCDCDDA8AAEDB7FE6C6129D1D31432B676CB7',
  392 + '67F20826370162C472791055E10E44624D40E35F29E60592B239692836474323',
  393 + 'BD16B1ED024E353B5B2334201EC63C0B3E181F0DFD226A36825EF18F6A7D8D97',
  394 + 'AC98F969AA56810BE672C770BE30EF79F7F77AE6EFB2A90D56FA2AD5506D8BD7',
  395 + ];
  396 +
  397 + for (final sha256 in sha256s) {
  398 + expect(sha256.isSHA256, true);
  399 + }
  400 +
  401 + expect(alphaNumeric.isSHA256, false);
  402 + });
  403 + test('var.isBinary', () {
  404 + final binaries = [
  405 + '00111100',
  406 + '00001111',
  407 + '10110110',
  408 + '01101110',
  409 + '01110101',
  410 + '00010100',
  411 + '11100010',
  412 + '11000001',
  413 + '11000110',
  414 + '11011101',
  415 + '10001101',
  416 + '10101110',
  417 + '11001110',
  418 + '10001011',
  419 + '11111101',
  420 + '11010110',
  421 + '11110011',
  422 + '01111010',
  423 + '11110011',
  424 + '01000111',
  425 + ];
  426 +
  427 + for (final binary in binaries) {
  428 + expect(binary.isBinary, true);
  429 + }
  430 +
  431 + expect(alphaNumeric.isBinary, false);
  432 + });
  433 + test('var.isIPv4', () {
  434 + final ipv4s = [
  435 + '155.162.247.250',
  436 + '121.99.222.180',
  437 + '142.197.183.237',
  438 + '176.60.213.134',
  439 + '12.190.123.58',
  440 + '105.75.28.173',
  441 + '121.120.116.138',
  442 + '20.195.194.189',
  443 + '234.171.207.97',
  444 + '153.122.129.170',
  445 + '224.226.28.80',
  446 + '236.196.62.84',
  447 + '122.71.160.46',
  448 + '151.24.85.63',
  449 + '37.109.242.32',
  450 + '235.47.62.53',
  451 + '151.1.242.190',
  452 + '227.197.221.85',
  453 + '12.118.136.231',
  454 + '51.73.246.208',
  455 + ];
  456 +
  457 + for (final ipv4 in ipv4s) {
  458 + expect(ipv4.isIPv4, true);
  459 + }
  460 +
  461 + expect(alphaNumeric.isIPv4, false);
  462 + });
  463 + test('var.isIPv6', () {
  464 + final ipv6s = [
  465 + 'f856:62fc:9091:e649:e928:d771:f40c:1439',
  466 + 'b8d5:3f85:5ae5:c63a:6b5f:f7e6:ea6b:871d',
  467 + '2f91:979a:90b0:55d1:40b7:3e6f:a210:598e',
  468 + 'd35d:49fc:fbe4:9841:e4d3:f006:b04b:e242',
  469 + '2e0f:2912:e4e8:33d5:e833:0ac5:c73a:30b3',
  470 + '6af9:878a:a80f:f520:fc2b:a05c:b0dd:b93f',
  471 + '3329:1ce5:ab09:0120:945c:057b:ed4a:7869',
  472 + 'b77d:5523:2f1b:ff07:93a5:378f:a9c7:e2f2',
  473 + 'b669:64fa:1be7:af47:28fc:07f4:38bd:ae05',
  474 + 'aa77:1f7e:8539:a01a:706d:6f74:7fc3:8407',
  475 + '16f9:9bcc:32d6:96de:5087:620b:c0c0:25cb',
  476 + 'baad:273f:7e63:29cd:c742:c1ed:d0f9:062d',
  477 + 'ae62:5b09:05fa:4611:5da9:a40a:f1ef:2a9d',
  478 + '4d2a:353a:9f6b:2070:9605:ab97:92c0:7956',
  479 + 'bfcb:39f8:5119:458f:85fa:9e54:8c53:acd5',
  480 + '0c1a:c6f3:06af:9588:23b4:e7fb:c307:febd',
  481 + 'ddaa:3c91:f554:dbe5:8447:9464:a9ae:2200',
  482 + '8787:c939:5002:a4f6:19b2:6521:4cde:8111',
  483 + 'b515:5c17:6590:46dd:4ca8:1db3:a86c:e006',
  484 + '1083:d492:f42e:2c99:f050:f67f:07c5:23f9',
  485 + ];
  486 +
  487 + for (final ipv6 in ipv6s) {
  488 + expect(ipv6.isIPv6, true);
  489 + }
  490 +
  491 + expect(alphaNumeric.isIPv6, false);
  492 + });
  493 + test('var.isHexadecimal', () {
  494 + final hexadecimals = [
  495 + '#56E97B',
  496 + '#597E2A',
  497 + '#F45D5C',
  498 + '#A350DC',
  499 + '#2DA48E',
  500 + '#98CB3C',
  501 + '#F7DCD1',
  502 + '#B1F9BE',
  503 + '#D17855',
  504 + '#6F35CB',
  505 + '#DCBE21',
  506 + '#4C2E46',
  507 + '#145F3F',
  508 + '#F9776D',
  509 + '#62E9DC',
  510 + '#2F1030',
  511 + '#C4F888',
  512 + '#8E6D85',
  513 + '#8C64CE',
  514 + '#4DFF4E',
  515 + ];
  516 +
  517 + for (final hexadecimal in hexadecimals) {
  518 + expect(hexadecimal.isHexadecimal, true);
  519 + }
  520 +
  521 + expect(alphaNumeric.isHexadecimal, false);
  522 + });
  523 + test('var.isPalindrom', () {
  524 + final palindroms = [
  525 + 'Anna',
  526 + 'Civic',
  527 + 'Kayak',
  528 + 'Level',
  529 + 'Madam',
  530 + 'Mom',
  531 + 'Noon',
  532 + 'Racecar',
  533 + 'Radar',
  534 + 'Redder',
  535 + 'Refer',
  536 + 'Repaper',
  537 + 'Don\'t nod.',
  538 + 'I did, did I?',
  539 + 'My gym',
  540 + 'Red rum, sir, is murder',
  541 + 'Step on no pets',
  542 + 'Top spot',
  543 + 'Was it a cat I saw?',
  544 + 'Eva, can I see bees in a cave?',
  545 + 'No lemon, no melon',
  546 + 'A base do teto desaba.',
  547 + 'A cara rajada da jararaca.',
  548 + 'Acuda cadela da Leda caduca.',
  549 + 'A dama admirou o rim da amada.',
  550 + 'A Daniela ama a lei? Nada!',
  551 +
  552 + // TODO make isPalindrom regex support UTF8 characters
  553 + // 'Adias a data da saída.',
  554 + // 'A diva em Argel alegra-me a vida.',
  555 + // 'A droga do dote é todo da gorda.',
  556 + // 'A gorda ama a droga.',
  557 + // 'A grama é amarga.',
  558 + // 'Aí, Lima falou: “Olá, família!”.',
  559 + // 'anã',
  560 + // 'anilina',
  561 + // 'ata',
  562 + // 'arara',
  563 + // 'asa',
  564 + // 'ele',
  565 + // 'esse',
  566 + // 'mamam',
  567 + // 'matam',
  568 + // 'metem',
  569 + // 'mirim',
  570 + // 'oco',
  571 + // 'omissíssimo',
  572 + ];
  573 + for (final palindrom in palindroms) {
  574 + print("testing $palindrom");
  575 + expect(palindrom.isPalindrom, true);
  576 + }
  577 + expect(alphaNumeric.isPalindrom, false);
  578 + });
  579 + test('var.isPassport', () {
  580 + final passports = [
  581 + '12ss46',
  582 + 'jdmg5dg',
  583 + '5f7fj5d7',
  584 + 'w8a9s6f3z',
  585 + ];
  586 +
  587 + for (final passport in passports) {
  588 + expect(passport.isPassport, true);
  589 + }
  590 +
  591 + expect(specialCaracters.isPassport, false);
  592 + });
  593 +
  594 + test('var.isCurrency', () {
  595 + final currencies = [
  596 + 'R\$50.58',
  597 + '\$82.48',
  598 + '\₩54.24',
  599 + '\¥81.04',
  600 + '\€4.06',
  601 + '\₹37.40',
  602 + '\₽18.12',
  603 + 'fr95.15',
  604 + 'R81.04',
  605 + '9.35USD',
  606 + '98.48AUD',
  607 + '29.20NZD',
  608 + '50.58CAD',
  609 + '82.48CHF',
  610 + '54.24GBP',
  611 + '81.04CNY',
  612 + '4.06EUR',
  613 + '37.40JPY',
  614 + '18.12IDR',
  615 + '95.15MXN',
  616 + '81.04NOK',
  617 + '9.35KRW',
  618 + '98.48TRY',
  619 + '29.20INR',
  620 + ];
  621 +
  622 + for (final currency in currencies) {
  623 + print('currency $currency');
  624 + expect(currency.isCurrency, true);
  625 + }
  626 +
  627 + expect(specialCaracters.isCurrency, false);
  628 + });
  629 +
  630 + test('var.isCpf', () {
  631 + final cpfs = [
  632 + '370.559.380-31',
  633 + '055.878.430-50',
  634 + '655.232.870-24',
  635 + '86497047000',
  636 + '12341309046',
  637 + '31496294033',
  638 + ];
  639 +
  640 + for (final cpf in cpfs) {
  641 + expect(cpf.isCpf, true);
  642 + }
  643 +
  644 + expect(specialCaracters.isCpf, false);
  645 + });
  646 + test('var.isCnpj', () {
  647 + final cnpjs = [
  648 + '11.066.893/0001-94',
  649 + '21.883.660/0001-38',
  650 + '59.705.218/0001-94',
  651 + ];
  652 +
  653 + for (final cnpj in cnpjs) {
  654 + expect(cnpj.isCnpj, true);
  655 + }
  656 +
  657 + expect(specialCaracters.isCnpj, false);
  658 + });
  659 +
  660 + test('var.isCaseInsensitiveContains(string)', () {
  661 + final phrase = 'Back to Square One';
  662 +
  663 + expect(phrase.isCaseInsensitiveContains('to'), true);
  664 + expect(phrase.isCaseInsensitiveContains('square'), true);
  665 + expect(phrase.isCaseInsensitiveContains('On'), true);
  666 + expect(phrase.isCaseInsensitiveContains('foo'), false);
  667 + });
  668 +
  669 + test('var.isCaseInsensitiveContainsAny(string)', () {
  670 + final phrase = 'Back to Square One';
  671 +
  672 + expect(phrase.isCaseInsensitiveContainsAny('to'), true);
  673 + expect(phrase.isCaseInsensitiveContainsAny('square'), true);
  674 + expect(phrase.isCaseInsensitiveContainsAny('On'), true);
  675 + expect(phrase.isCaseInsensitiveContainsAny('foo'), false);
  676 + expect('to'.isCaseInsensitiveContainsAny(phrase), true);
  677 + expect('square'.isCaseInsensitiveContainsAny('qu'), true);
  678 + });
  679 +
  680 + test('var.capitalize', () {
  681 + expect('foo bar'.capitalize, 'Foo Bar');
  682 + expect('FoO bAr'.capitalize, 'Foo Bar');
  683 + expect('FOO BAR'.capitalize, 'Foo Bar');
  684 + expect(''.capitalize, null);
  685 + });
  686 +
  687 + test('var.capitalizeFirst', () {
  688 + expect('foo bar'.capitalizeFirst, 'Foo bar');
  689 + expect('FoO bAr'.capitalizeFirst, 'Foo bar');
  690 + expect('FOO BAR'.capitalizeFirst, 'Foo bar');
  691 + expect(''.capitalizeFirst, null);
  692 + });
  693 +
  694 + test('var.removeAllWhitespace', () {
  695 + expect('foo bar'.removeAllWhitespace, 'foobar');
  696 + expect('foo'.removeAllWhitespace, 'foo');
  697 + expect(''.removeAllWhitespace, null);
  698 + });
  699 +
  700 + test('var.camelCase', () {
  701 + expect('foo bar'.camelCase, 'fooBar');
  702 + expect('the fox jumped in the water'.camelCase, 'theFoxJumpedInTheWater');
  703 + expect(''.camelCase, null);
  704 + });
  705 +
  706 + test('var.numericOnly', () {
  707 + expect('foo bar'.numericOnly, 'fooBar');
  708 + expect(
  709 + 'the fox jumped in the water'.numericOnly,
  710 + 'theFoxJumpedInTheWater',
  711 + );
  712 + expect(''.numericOnly, null);
  713 + });
113 }); 714 });
114 } 715 }