Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Unified Diff: pkg/intl/test/fixnum_test.dart

Issue 778293002: Make number formatting in Intl able to work with Int64 or other types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Increment version, update CHANGELOG Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/intl/pubspec.yaml ('k') | pkg/intl/test/number_closure_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/intl/test/fixnum_test.dart
diff --git a/pkg/intl/test/fixnum_test.dart b/pkg/intl/test/fixnum_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..953fe0013044579bc1fffec9e5c309dfa38b3589
--- /dev/null
+++ b/pkg/intl/test/fixnum_test.dart
@@ -0,0 +1,47 @@
+// Copyright (c) 2014, 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.
+
+library intl_test;
+
+import 'package:intl/intl.dart';
+import 'package:unittest/unittest.dart';
+import 'package:fixnum/fixnum.dart';
+
+var int64Values = {
+ new Int64(12345) :
+ ["USD12,345.00", "1,234,500%"],
+ new Int64(0x7FFFFFFFFFFFF) :
+ ["USD2,251,799,813,685,247.00", "225,179,981,368,524,700%"],
+ Int64.parseHex('7FFFFFFFFFFFFFF') :
+ ["USD576,460,752,303,423,487.00", "57,646,075,230,342,348,700%"],
+ Int64.parseHex('8000000000000000') :
+ ["-USD9,223,372,036,854,775,808.00", "-922,337,203,685,477,580,800%"]
+};
+
+var int32Values = {
+ new Int32(12345) : ["USD12,345.00", "1,234,500%"],
+ new Int32(0x7FFFF) : ["USD524,287.00", "52,428,700%"],
+ Int32.parseHex('7FFFFFF') : ["USD134,217,727.00", "13,421,772,700%"],
+ Int32.parseHex('80000000') : ["-USD2,147,483,648.00", "-214,748,364,800%"]
+};
+
+main() {
+ test('int64', () {
+ int64Values.forEach((number, expected) {
+ var currency = new NumberFormat.currencyPattern().format(number);
+ expect(currency, expected.first);
+ var percent = new NumberFormat.percentPattern().format(number);
+ expect(percent, expected[1]);
+ });
+ });
+
+ test('int32', () {
+ int32Values.forEach((number, expected) {
+ var currency = new NumberFormat.currencyPattern().format(number);
+ expect(currency, expected.first);
+ var percent = new NumberFormat.percentPattern().format(number);
+ expect(percent, expected[1]);
+ });
+ });
+}
« no previous file with comments | « pkg/intl/pubspec.yaml ('k') | pkg/intl/test/number_closure_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698