Nipodemos

num and string partially done

... ... @@ -24,8 +24,10 @@ extension GetNumUtils on num {
/// print('currently running callback 1.2sec');
/// }
///```
Future delay([VoidCallback callback]) async =>
Future.delayed(Duration(milliseconds: (this * 1000).round()), callback);
Future delay([VoidCallback callback]) async => Future.delayed(
Duration(milliseconds: (this * 1000).round()),
callback,
);
/// Easy way to make Durations from numbers.
///
... ...
... ... @@ -4,18 +4,42 @@ import 'package:get/utils.dart';
void main() {
num x = 5;
num y = 7;
test('Test for var.isLowerThan(value)', () {
num z = 5;
var doubleX = 2.1;
var doubleY = 3.1;
var doubleZ = 5.0;
var pi = 3.14159265359;
group('num extensions text', () {
test('var.isLowerThan(value)', () {
expect(x.isLowerThan(y), true);
expect(y.isLowerThan(x), false);
expect(x.isLowerThan(z), false);
expect(doubleX.isLowerThan(doubleY), true);
expect(doubleY.isLowerThan(pi), true);
expect(x.isLowerThan(doubleX), false);
expect(z.isLowerThan(doubleZ), false);
});
test('Test for var.isGreaterThan(value)', () {
test('var.isGreaterThan(value)', () {
expect(x.isGreaterThan(y), false);
expect(y.isGreaterThan(x), true);
expect(x.isGreaterThan(z), false);
expect(doubleX.isGreaterThan(doubleY), false);
expect(doubleY.isGreaterThan(pi), false);
expect(pi.isGreaterThan(3.14159265359), false);
expect(y.isGreaterThan(doubleY), true);
expect(z.isGreaterThan(doubleZ), false);
});
test('Test for var.isGreaterThan(value)', () {
test('var.isEqual(value)', () {
expect(x.isEqual(y), false);
expect(y.isEqual(x), false);
expect(x.isEqual(5), true);
expect(y.isEqual(7), true);
expect(doubleX.isEqual(doubleY), false);
expect(doubleY.isEqual(pi), false);
expect(pi.isEqual(3.14159265359), true);
expect(z.isEqual(doubleZ), true);
});
});
}
... ...
... ... @@ -16,4 +16,99 @@ void main() {
expect(testString.isNullOrBlank, equals(true));
});
});
group('String extensions', () {
var text = "oi";
var digit = "5";
var specialCaracters = "#\$!%@";
var alphaNumeric = "123asd";
var numbers = "123";
var letters = "foo";
String notInitializedVar;
test('var.isNum', () {
expect(digit.isNum, true);
expect(text.isNum, false);
});
test('var.isNumericOnly', () {
expect(numbers.isNumericOnly, true);
expect(letters.isNumericOnly, false);
expect(specialCaracters.isNumericOnly, false);
expect(alphaNumeric.isNumericOnly, false);
});
test('var.isAlphabetOnly', () {
expect(alphaNumeric.isAlphabetOnly, false);
expect(numbers.isAlphabetOnly, false);
expect(letters.isAlphabetOnly, true);
});
test('var.isBool', () {
var trueString = 'true';
expect(notInitializedVar.isBool, false);
expect(letters.isBool, false);
expect(trueString.isBool, true);
});
test('var.isVectorFileName', () {
var path = "logo.svg";
var fullPath = "C:/Users/Getx/Documents/logo.svg";
expect(path.isVectorFileName, true);
expect(fullPath.isVectorFileName, true);
expect(alphaNumeric.isVectorFileName, false);
});
test('var.isImageFileName', () {
var jpgPath = "logo.jpg";
var jpegPath = "logo.jpeg";
var pngPath = "logo.png";
var gifPath = "logo.gif";
var bmpPath = "logo.bmp";
var svgPath = "logo.svg";
expect(jpgPath.isImageFileName, true);
expect(jpegPath.isImageFileName, true);
expect(pngPath.isImageFileName, true);
expect(gifPath.isImageFileName, true);
expect(bmpPath.isImageFileName, true);
expect(svgPath.isImageFileName, false);
});
test('var.isAudioFileName', () {
var mp3Path = "logo.mp3";
var wavPath = "logo.wav";
var wmaPath = "logo.wma";
var amrPath = "logo.amr";
var oggPath = "logo.ogg";
var svgPath = "logo.svg";
expect(mp3Path.isAudioFileName, true);
expect(wavPath.isAudioFileName, true);
expect(wmaPath.isAudioFileName, true);
expect(amrPath.isAudioFileName, true);
expect(oggPath.isAudioFileName, true);
expect(svgPath.isAudioFileName, false);
});
test('var.isVideoFileName', () {
var mp4Path = "logo.mp4";
var aviPath = "logo.avi";
var wmvPath = "logo.wmv";
var rmvbPath = "logo.rmvb";
var mpgPath = "logo.mpg";
var mpegPath = "logo.mpeg";
var threegpPath = "logo.3gp";
var svgPath = "logo.svg";
expect(mp4Path.isVideoFileName, true);
expect(aviPath.isVideoFileName, true);
expect(wmvPath.isVideoFileName, true);
expect(rmvbPath.isVideoFileName, true);
expect(mpgPath.isVideoFileName, true);
expect(mpegPath.isVideoFileName, true);
expect(threegpPath.isVideoFileName, true);
expect(svgPath.isAudioFileName, false);
});
});
}
... ...