mirror of
https://github.com/hanskokx/arcane_helper_utils.git
synced 2026-05-14 02:19:09 +02:00
v1.3.1
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import "package:arcane_helper_utils/arcane_helper_utils.dart";
|
||||
import "package:test/test.dart";
|
||||
|
||||
void main() {
|
||||
group("DoubleConverter", () {
|
||||
const converter = DoubleConverter();
|
||||
|
||||
test("fromJson converts valid string to double", () {
|
||||
expect(converter.fromJson("123.45"), 123.45);
|
||||
expect(converter.fromJson("-123.45"), -123.45);
|
||||
expect(converter.fromJson("0.0"), 0.0);
|
||||
});
|
||||
|
||||
test("fromJson handles null and invalid inputs", () {
|
||||
expect(converter.fromJson(null), null);
|
||||
expect(converter.fromJson(""), null);
|
||||
expect(converter.fromJson("invalid"), null);
|
||||
});
|
||||
|
||||
test("toJson converts double to string", () {
|
||||
expect(converter.toJson(123.45), "123.45");
|
||||
expect(converter.toJson(-123.45), "-123.45");
|
||||
expect(converter.toJson(0.0), "0.0");
|
||||
expect(converter.toJson(null), null);
|
||||
});
|
||||
});
|
||||
|
||||
group("IntegerConverter", () {
|
||||
const converter = IntegerConverter();
|
||||
|
||||
test("fromJson converts valid string to int", () {
|
||||
expect(converter.fromJson("123"), 123);
|
||||
expect(converter.fromJson("-123"), -123);
|
||||
expect(converter.fromJson("0"), 0);
|
||||
});
|
||||
|
||||
test("fromJson handles null and invalid inputs", () {
|
||||
expect(converter.fromJson(null), null);
|
||||
expect(converter.fromJson(""), null);
|
||||
expect(converter.fromJson("invalid"), null);
|
||||
expect(converter.fromJson("123.45"), null);
|
||||
});
|
||||
|
||||
test("toJson converts int to string", () {
|
||||
expect(converter.toJson(123), "123");
|
||||
expect(converter.toJson(-123), "-123");
|
||||
expect(converter.toJson(0), "0");
|
||||
expect(converter.toJson(null), null);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user