refactor(json): share scalar adapters

This commit is contained in:
edde746
2026-07-12 08:42:21 +02:00
parent 0ddd0a6c25
commit f08fceaee0
18 changed files with 49 additions and 38 deletions
+15
View File
@@ -33,6 +33,21 @@ void main() {
});
});
test('flexibleIntOrZero defaults unsupported values to zero', () {
expect(flexibleIntOrZero(3.9), 3);
expect(flexibleIntOrZero('42'), 42);
expect(flexibleIntOrZero(null), 0);
expect(flexibleIntOrZero('bad'), 0);
expect(flexibleIntOrZero(true), 0);
});
test('stringOrEmpty stringifies values and defaults null', () {
expect(stringOrEmpty('value'), 'value');
expect(stringOrEmpty(42), '42');
expect(stringOrEmpty(true), 'true');
expect(stringOrEmpty(null), '');
});
group('flexibleBool', () {
test('returns bool as-is', () {
expect(flexibleBool(true), isTrue);