OLD | NEW |
1 /** | 1 /** |
2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
3 * for details. All rights reserved. Use of this source code is governed by a | 3 * for details. All rights reserved. Use of this source code is governed by a |
4 * BSD-style license that can be found in the LICENSE file. | 4 * BSD-style license that can be found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 library number_format_test; | 7 library number_format_test; |
8 | 8 |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 import 'package:intl/number_symbols_data.dart'; | 10 import 'package:intl/number_symbols_data.dart'; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // Verify that we can pass null in order to specify the currency symbol | 180 // Verify that we can pass null in order to specify the currency symbol |
181 // but use the default locale. | 181 // but use the default locale. |
182 var defaultLocale = new NumberFormat.currencyPattern(null, 'Smurfs'); | 182 var defaultLocale = new NumberFormat.currencyPattern(null, 'Smurfs'); |
183 formatted = defaultLocale.format(amount); | 183 formatted = defaultLocale.format(amount); |
184 // We don't know what the exact format will be, but it should have Smurfs. | 184 // We don't know what the exact format will be, but it should have Smurfs. |
185 expect(formatted.contains('Smurfs'), isTrue); | 185 expect(formatted.contains('Smurfs'), isTrue); |
186 readBack = defaultLocale.parse(formatted); | 186 readBack = defaultLocale.parse(formatted); |
187 expect(readBack, amount); | 187 expect(readBack, amount); |
188 }); | 188 }); |
189 | 189 |
| 190 test("Delta percent format", () { |
| 191 var f = new NumberFormat("+#,##0%;-#,##0%"); |
| 192 expect(f.format(-0.07), "-7%"); |
| 193 expect(f.format(0.12), "+12%"); |
| 194 }); |
| 195 |
190 test('Unparseable', () { | 196 test('Unparseable', () { |
191 var format = new NumberFormat.currencyPattern(); | 197 var format = new NumberFormat.currencyPattern(); |
192 expect(() => format.parse("abcdefg"), throwsFormatException); | 198 expect(() => format.parse("abcdefg"), throwsFormatException); |
193 expect(() => format.parse(""), throwsFormatException); | 199 expect(() => format.parse(""), throwsFormatException); |
194 expect(() => format.parse("1.0zzz"), throwsFormatException); | 200 expect(() => format.parse("1.0zzz"), throwsFormatException); |
195 expect(() => format.parse("-∞+1"), throwsFormatException); | 201 expect(() => format.parse("-∞+1"), throwsFormatException); |
196 }); | 202 }); |
197 } | 203 } |
OLD | NEW |