This repository has been archived by the owner on May 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from davidmorgan/fix-maps
Fix issue with BuiltMap deserialization. Add test.
- Loading branch information
Showing
12 changed files
with
239 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# Changelog | ||
|
||
## 0.1.2 | ||
|
||
- Fix issue with BuiltMap deserialization. | ||
|
||
## 0.1.1 | ||
|
||
- Fix error in pubspec.yaml. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2016, Google Inc. Please see the AUTHORS file for details. | ||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
library collections; | ||
|
||
import 'package:built_collection/built_collection.dart'; | ||
import 'package:built_json/built_json.dart'; | ||
import 'package:built_value/built_value.dart'; | ||
|
||
part 'collections.g.dart'; | ||
|
||
/// Example built_value type containing collections. | ||
abstract class Collections | ||
implements Built<Collections, CollectionsBuilder> { | ||
/// Example of how to make a built_value type serializable. | ||
/// | ||
/// Declare a static final [Serializers] field called `serializer`. | ||
/// The built_json code generator will provide the implementation. You need to | ||
/// do this for every type you want to serialize. | ||
static final Serializer<Collections> serializer = _$collectionsSerializer; | ||
|
||
BuiltList<String> get list; | ||
BuiltSet<int> get set; | ||
BuiltMap<String, int> get map; | ||
|
||
Collections._(); | ||
factory Collections([updates(CollectionsBuilder b)]) = _$Collections; | ||
} | ||
|
||
/// Builder class for [Collections]. | ||
abstract class CollectionsBuilder | ||
implements Builder<Collections, CollectionsBuilder> { | ||
ListBuilder<String> list = new ListBuilder<String>(); | ||
SetBuilder<int> set = new SetBuilder<int>(); | ||
MapBuilder<String, int> map = new MapBuilder<String, int>(); | ||
|
||
CollectionsBuilder._(); | ||
factory CollectionsBuilder() = _$CollectionsBuilder; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) 2016, Google Inc. Please see the AUTHORS file for details. | ||
|
||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
import 'package:example/collections.dart'; | ||
import 'package:example/serializers.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('Collections', () { | ||
final data = new Collections((b) => b | ||
..list.add('one') | ||
..set.add(2) | ||
..map['three'] = 4); | ||
final serialized = [ | ||
'Collections', | ||
'list', | ||
['one'], | ||
'set', | ||
[2], | ||
'map', | ||
['three', 4], | ||
]; | ||
|
||
test('can be serialized', () { | ||
expect(serializers.serialize(data), serialized); | ||
}); | ||
|
||
test('can be deserialized', () { | ||
expect(serializers.deserialize(serialized), data); | ||
}); | ||
}); | ||
} |