Skip to content

Commit

Permalink
Added tab support (#29)
Browse files Browse the repository at this point in the history
* added tab support

* Formatted code
  • Loading branch information
jrote1 authored Feb 20, 2017
1 parent 5edd124 commit ada5f94
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/src/converters/class_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ class ClassConverter implements Converter {
return DateTime.parse(nativeObjectValue);
}
if (_isTypeEnum(type)) {
return _typeInformationRetriever.getEnumGeneratedMap(type)[
nativeObjectValue];
return _typeInformationRetriever
.getEnumGeneratedMap(type)[nativeObjectValue];
}

if (type == double && nativeObjectValue != null) {
Expand Down
3 changes: 2 additions & 1 deletion lib/src/converters/json_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class JsonConverter implements Converter {
stringBuffer.write("\"" +
baseObjectData.value
.replaceAll(r"\", r'\\')
.replaceAll("\"", '\\"') +
.replaceAll("\"", '\\"')
.replaceAll("\t", "\\t") +
"\"");
else if (baseObjectData.value is DateTime)
stringBuffer.write('"${baseObjectData.value.toString()}"');
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ dependencies:
path: '>=1.0.0 <2.0.0'
reflective: ^0.0.29
dev_dependencies:
test: any
transformer_test: any
test: 0.12.19+1
transformer_test: 0.2.1+1
23 changes: 21 additions & 2 deletions test/all_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
library nomirrorsmap.tests;

import 'dart:io';
import 'package:test/test.dart';
import 'package:nomirrorsmap/nomirrorsmap.dart';
import 'package:nomirrorsmap/nomirrorsmap_mirrors.dart';
Expand Down Expand Up @@ -45,6 +46,24 @@ main() async {
expect(result, "null");
});

test("Can serialize with tab", () {
var previousJson = noMirrorsMap.convert(
new NoTypeTestPropertyClass()
..id = 1
..name = "\t",
new ClassConverter(),
new JsonConverter());
print(previousJson);
var result = noMirrorsMap.convert(
new NoTypeTestPropertyClass()
..id = 1
..name = previousJson,
new ClassConverter(),
new JsonConverter());

expect(result, endsWith('''"name\\":\\"\\\\t\\"}"}'''));
});

test("Can serialize to Pascal case", () {
var result = noMirrorsMap.convert(
new Person()
Expand Down Expand Up @@ -92,8 +111,8 @@ main() async {
});

test("Can deserialize to object", () {
ClassConverter.converters[
Duration] = new CustomClassConverter<Duration>()
ClassConverter
.converters[Duration] = new CustomClassConverter<Duration>()
..to = ((ClassIntermediateObject input) {
return new Duration(
minutes:
Expand Down

0 comments on commit ada5f94

Please sign in to comment.