trphoenix
2018-11-12 29fbfc5dd1d55d189f23eb6d32f000252f92985f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2018, the Dart project authors.  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.
 
@TestOn('vm')
 
import 'dart:convert';
import 'dart:io';
 
import 'package:test/test.dart';
 
import '../test_file_utils.dart';
import '../test_utils.dart';
import 'json_literal.dart';
 
void main() {
  test('literal round-trip', () {
    final dataFilePath = testFilePath('test', 'literal', 'json_literal.json');
    final dataFile = File(dataFilePath);
 
    final dataString = loudEncode(json.decode(dataFile.readAsStringSync()));
    // FYI: nice to re-write the test data when it's changed to keep it pretty
    // ... but not a good idea to ship this
    // dataFile.writeAsStringSync(dataString.replaceAll('\u007F', '\\u007F'));
    final dartString = loudEncode(data);
 
    expect(dartString, dataString);
  });
 
  test('naughty strings', () {
    final dataFilePath =
        testFilePath('test', 'literal', 'big-list-of-naughty-strings.json');
    final dataFile = File(dataFilePath);
 
    final dataString = loudEncode(json.decode(dataFile.readAsStringSync()));
    final dartString = loudEncode(naughtyStrings);
 
    expect(dartString, dataString);
  });
}