Showing
3 changed files
with
126 additions
and
5 deletions
@@ -24,8 +24,10 @@ extension GetNumUtils on num { | @@ -24,8 +24,10 @@ extension GetNumUtils on num { | ||
24 | /// print('currently running callback 1.2sec'); | 24 | /// print('currently running callback 1.2sec'); |
25 | /// } | 25 | /// } |
26 | ///``` | 26 | ///``` |
27 | - Future delay([VoidCallback callback]) async => | ||
28 | - Future.delayed(Duration(milliseconds: (this * 1000).round()), callback); | 27 | + Future delay([VoidCallback callback]) async => Future.delayed( |
28 | + Duration(milliseconds: (this * 1000).round()), | ||
29 | + callback, | ||
30 | + ); | ||
29 | 31 | ||
30 | /// Easy way to make Durations from numbers. | 32 | /// Easy way to make Durations from numbers. |
31 | /// | 33 | /// |
@@ -4,18 +4,42 @@ import 'package:get/utils.dart'; | @@ -4,18 +4,42 @@ import 'package:get/utils.dart'; | ||
4 | void main() { | 4 | void main() { |
5 | num x = 5; | 5 | num x = 5; |
6 | num y = 7; | 6 | num y = 7; |
7 | - test('Test for var.isLowerThan(value)', () { | 7 | + num z = 5; |
8 | + | ||
9 | + var doubleX = 2.1; | ||
10 | + var doubleY = 3.1; | ||
11 | + var doubleZ = 5.0; | ||
12 | + var pi = 3.14159265359; | ||
13 | + | ||
14 | + group('num extensions text', () { | ||
15 | + test('var.isLowerThan(value)', () { | ||
8 | expect(x.isLowerThan(y), true); | 16 | expect(x.isLowerThan(y), true); |
9 | expect(y.isLowerThan(x), false); | 17 | expect(y.isLowerThan(x), false); |
18 | + expect(x.isLowerThan(z), false); | ||
19 | + expect(doubleX.isLowerThan(doubleY), true); | ||
20 | + expect(doubleY.isLowerThan(pi), true); | ||
21 | + expect(x.isLowerThan(doubleX), false); | ||
22 | + expect(z.isLowerThan(doubleZ), false); | ||
10 | }); | 23 | }); |
11 | - test('Test for var.isGreaterThan(value)', () { | 24 | + test('var.isGreaterThan(value)', () { |
12 | expect(x.isGreaterThan(y), false); | 25 | expect(x.isGreaterThan(y), false); |
13 | expect(y.isGreaterThan(x), true); | 26 | expect(y.isGreaterThan(x), true); |
27 | + expect(x.isGreaterThan(z), false); | ||
28 | + expect(doubleX.isGreaterThan(doubleY), false); | ||
29 | + expect(doubleY.isGreaterThan(pi), false); | ||
30 | + expect(pi.isGreaterThan(3.14159265359), false); | ||
31 | + expect(y.isGreaterThan(doubleY), true); | ||
32 | + expect(z.isGreaterThan(doubleZ), false); | ||
14 | }); | 33 | }); |
15 | - test('Test for var.isGreaterThan(value)', () { | 34 | + test('var.isEqual(value)', () { |
16 | expect(x.isEqual(y), false); | 35 | expect(x.isEqual(y), false); |
17 | expect(y.isEqual(x), false); | 36 | expect(y.isEqual(x), false); |
18 | expect(x.isEqual(5), true); | 37 | expect(x.isEqual(5), true); |
19 | expect(y.isEqual(7), true); | 38 | expect(y.isEqual(7), true); |
39 | + expect(doubleX.isEqual(doubleY), false); | ||
40 | + expect(doubleY.isEqual(pi), false); | ||
41 | + expect(pi.isEqual(3.14159265359), true); | ||
42 | + expect(z.isEqual(doubleZ), true); | ||
43 | + }); | ||
20 | }); | 44 | }); |
21 | } | 45 | } |
@@ -16,4 +16,99 @@ void main() { | @@ -16,4 +16,99 @@ void main() { | ||
16 | expect(testString.isNullOrBlank, equals(true)); | 16 | expect(testString.isNullOrBlank, equals(true)); |
17 | }); | 17 | }); |
18 | }); | 18 | }); |
19 | + | ||
20 | + 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"; | ||
27 | + String notInitializedVar; | ||
28 | + | ||
29 | + test('var.isNum', () { | ||
30 | + expect(digit.isNum, true); | ||
31 | + expect(text.isNum, false); | ||
32 | + }); | ||
33 | + | ||
34 | + test('var.isNumericOnly', () { | ||
35 | + expect(numbers.isNumericOnly, true); | ||
36 | + expect(letters.isNumericOnly, false); | ||
37 | + expect(specialCaracters.isNumericOnly, false); | ||
38 | + expect(alphaNumeric.isNumericOnly, false); | ||
39 | + }); | ||
40 | + | ||
41 | + test('var.isAlphabetOnly', () { | ||
42 | + expect(alphaNumeric.isAlphabetOnly, false); | ||
43 | + expect(numbers.isAlphabetOnly, false); | ||
44 | + expect(letters.isAlphabetOnly, true); | ||
45 | + }); | ||
46 | + | ||
47 | + test('var.isBool', () { | ||
48 | + var trueString = 'true'; | ||
49 | + expect(notInitializedVar.isBool, false); | ||
50 | + expect(letters.isBool, false); | ||
51 | + expect(trueString.isBool, true); | ||
52 | + }); | ||
53 | + | ||
54 | + test('var.isVectorFileName', () { | ||
55 | + var path = "logo.svg"; | ||
56 | + var fullPath = "C:/Users/Getx/Documents/logo.svg"; | ||
57 | + expect(path.isVectorFileName, true); | ||
58 | + expect(fullPath.isVectorFileName, true); | ||
59 | + expect(alphaNumeric.isVectorFileName, false); | ||
60 | + }); | ||
61 | + | ||
62 | + 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"; | ||
69 | + | ||
70 | + expect(jpgPath.isImageFileName, true); | ||
71 | + expect(jpegPath.isImageFileName, true); | ||
72 | + expect(pngPath.isImageFileName, true); | ||
73 | + expect(gifPath.isImageFileName, true); | ||
74 | + expect(bmpPath.isImageFileName, true); | ||
75 | + expect(svgPath.isImageFileName, false); | ||
76 | + }); | ||
77 | + | ||
78 | + 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"; | ||
85 | + | ||
86 | + expect(mp3Path.isAudioFileName, true); | ||
87 | + expect(wavPath.isAudioFileName, true); | ||
88 | + expect(wmaPath.isAudioFileName, true); | ||
89 | + expect(amrPath.isAudioFileName, true); | ||
90 | + expect(oggPath.isAudioFileName, true); | ||
91 | + expect(svgPath.isAudioFileName, false); | ||
92 | + }); | ||
93 | + | ||
94 | + 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"; | ||
103 | + | ||
104 | + expect(mp4Path.isVideoFileName, true); | ||
105 | + expect(aviPath.isVideoFileName, true); | ||
106 | + expect(wmvPath.isVideoFileName, true); | ||
107 | + expect(rmvbPath.isVideoFileName, true); | ||
108 | + expect(mpgPath.isVideoFileName, true); | ||
109 | + expect(mpegPath.isVideoFileName, true); | ||
110 | + expect(threegpPath.isVideoFileName, true); | ||
111 | + expect(svgPath.isAudioFileName, false); | ||
112 | + }); | ||
113 | + }); | ||
19 | } | 114 | } |
-
Please register or login to post a comment