diff --git a/perf-test/test/unit/test.value.decorators.dart b/perf-test/test/unit/test.value.decorators.dart index 68fed1a..221587b 100644 --- a/perf-test/test/unit/test.value.decorators.dart +++ b/perf-test/test/unit/test.value.decorators.dart @@ -309,6 +309,41 @@ void testValueDecorators() { JsonMapper().removeAdapter(adapter); }); + test('List of Lists with null', () { + // given + final json = '''{ + "lists": [ + null, + null, + [{}, {}, null], + [{}, {}, {}] + ] +}'''; + final adapter = JsonMapperAdapter(valueDecorators: { + typeOf>>(): (value) { + (value as List).removeWhere((x) => x == null); + return value.cast>(); + }, + typeOf>(): (value) { + (value as List).removeWhere((x) => x == null); + return value.cast(); + } + }); + JsonMapper().useAdapter(adapter); + + // when + final target = JsonMapper.deserialize(json)!; + + // then + expect(target.lists?.length, 2); + expect(target.lists?.first.length, 2); + expect(target.lists?.last.length, 3); + expect(target.lists?.first.first, TypeMatcher()); + expect(target.lists?.last.first, TypeMatcher()); + + JsonMapper().removeAdapter(adapter); + }); + test('List of Lists with constructor', () { // given final json = '''{