OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'package:unittest/src/pretty_print.dart'; | 5 import 'package:unittest/src/pretty_print.dart'; |
6 import 'package:unittest/unittest.dart'; | 6 import 'package:unittest/unittest.dart'; |
7 | 7 |
8 void main() { | 8 void main() { |
9 test('with primitive objects', () { | 9 test('with primitive objects', () { |
10 expect(prettyPrint(12), equals('<12>')); | 10 expect(prettyPrint(12), equals('<12>')); |
(...skipping 30 matching lines...) Expand all Loading... |
41 test('containing a multiline string', () { | 41 test('containing a multiline string', () { |
42 expect(prettyPrint(['foo', 'bar\nbaz\nbip', 'qux']), equals("[\n" | 42 expect(prettyPrint(['foo', 'bar\nbaz\nbip', 'qux']), equals("[\n" |
43 " 'foo',\n" | 43 " 'foo',\n" |
44 " 'bar\\n'\n" | 44 " 'bar\\n'\n" |
45 " 'baz\\n'\n" | 45 " 'baz\\n'\n" |
46 " 'bip',\n" | 46 " 'bip',\n" |
47 " 'qux'\n" | 47 " 'qux'\n" |
48 "]")); | 48 "]")); |
49 }); | 49 }); |
50 | 50 |
| 51 test('containing a matcher', () { |
| 52 expect(prettyPrint(['foo', endsWith('qux')]), |
| 53 equals("['foo', <a string ending with 'qux'>]")); |
| 54 }); |
| 55 |
51 test("that's under maxLineLength", () { | 56 test("that's under maxLineLength", () { |
52 expect(prettyPrint([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], maxLineLength: 30), | 57 expect(prettyPrint([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], maxLineLength: 30), |
53 equals("[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]")); | 58 equals("[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]")); |
54 }); | 59 }); |
55 | 60 |
56 test("that's over maxLineLength", () { | 61 test("that's over maxLineLength", () { |
57 expect(prettyPrint([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], maxLineLength: 29), | 62 expect(prettyPrint([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], maxLineLength: 29), |
58 equals("[\n" | 63 equals("[\n" |
59 " 0,\n" | 64 " 0,\n" |
60 " 1,\n" | 65 " 1,\n" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 }); | 136 }); |
132 | 137 |
133 test('containing a multiline string key/value pair', () { | 138 test('containing a multiline string key/value pair', () { |
134 expect(prettyPrint({'foo\nbar': 'baz\nqux'}), equals("{\n" | 139 expect(prettyPrint({'foo\nbar': 'baz\nqux'}), equals("{\n" |
135 " 'foo\\n'\n" | 140 " 'foo\\n'\n" |
136 " 'bar': 'baz\\n'\n" | 141 " 'bar': 'baz\\n'\n" |
137 " 'qux'\n" | 142 " 'qux'\n" |
138 "}")); | 143 "}")); |
139 }); | 144 }); |
140 | 145 |
| 146 test('containing a matcher key', () { |
| 147 expect(prettyPrint({endsWith('bar'): 'qux'}), |
| 148 equals("{<a string ending with 'bar'>: 'qux'}")); |
| 149 }); |
| 150 |
| 151 test('containing a matcher value', () { |
| 152 expect(prettyPrint({'foo': endsWith('qux')}), |
| 153 equals("{'foo': <a string ending with 'qux'>}")); |
| 154 }); |
| 155 |
141 test("that's under maxLineLength", () { | 156 test("that's under maxLineLength", () { |
142 expect(prettyPrint({'0': 1, '2': 3, '4': 5, '6': 7}, maxLineLength: 32), | 157 expect(prettyPrint({'0': 1, '2': 3, '4': 5, '6': 7}, maxLineLength: 32), |
143 equals("{'0': 1, '2': 3, '4': 5, '6': 7}")); | 158 equals("{'0': 1, '2': 3, '4': 5, '6': 7}")); |
144 }); | 159 }); |
145 | 160 |
146 test("that's over maxLineLength", () { | 161 test("that's over maxLineLength", () { |
147 expect(prettyPrint({'0': 1, '2': 3, '4': 5, '6': 7}, maxLineLength: 31), | 162 expect(prettyPrint({'0': 1, '2': 3, '4': 5, '6': 7}, maxLineLength: 31), |
148 equals("{\n" | 163 equals("{\n" |
149 " '0': 1,\n" | 164 " '0': 1,\n" |
150 " '2': 3,\n" | 165 " '2': 3,\n" |
(...skipping 21 matching lines...) Expand all Loading... |
172 expect(prettyPrint({'0': 1, '2': 3, '4': 5, '6': 7}, maxItems: 4), | 187 expect(prettyPrint({'0': 1, '2': 3, '4': 5, '6': 7}, maxItems: 4), |
173 equals("{'0': 1, '2': 3, '4': 5, '6': 7}")); | 188 equals("{'0': 1, '2': 3, '4': 5, '6': 7}")); |
174 }); | 189 }); |
175 | 190 |
176 test("that's over maxItems", () { | 191 test("that's over maxItems", () { |
177 expect(prettyPrint({'0': 1, '2': 3, '4': 5, '6': 7}, maxItems: 3), | 192 expect(prettyPrint({'0': 1, '2': 3, '4': 5, '6': 7}, maxItems: 3), |
178 equals("{'0': 1, '2': 3, ...}")); | 193 equals("{'0': 1, '2': 3, ...}")); |
179 }); | 194 }); |
180 }); | 195 }); |
181 } | 196 } |
OLD | NEW |