Skip to content

Commit

Permalink
Add @curran’s tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Jan 31, 2017
1 parent db3cbfb commit 05c8ddb
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/locale-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,31 @@ tape("formatLocale({grouping: [sizes…]}) observes the specified group sizes",
test.end();
});

tape("formatLocale(…) can format numbers using the Indian numbering system.", function(test) {
var format = d3.formatLocale(require("../locale/en-IN")).format(",");
test.equal(format(10), "10");
test.equal(format(100), "100");
test.equal(format(1000), "1,000");
test.equal(format(10000), "10,000");
test.equal(format(100000), "1,00,000");
test.equal(format(1000000), "10,00,000");
test.equal(format(10000000), "1,00,00,000");
test.equal(format(10000000.4543), "1,00,00,000.4543");
test.equal(format(1000.321), "1,000.321");
test.equal(format(10.5), "10.5");
test.equal(format(-10), "-10");
test.equal(format(-100), "-100");
test.equal(format(-1000), "-1,000");
test.equal(format(-10000), "-10,000");
test.equal(format(-100000), "-1,00,000");
test.equal(format(-1000000), "-10,00,000");
test.equal(format(-10000000), "-1,00,00,000");
test.equal(format(-10000000.4543), "-1,00,00,000.4543");
test.equal(format(-1000.321), "-1,000.321");
test.equal(format(-10.5), "-10.5");
test.end();
});

tape("formatLocale({thousands: separator}) observes the specified group separator", function(test) {
test.equal(d3.formatLocale({decimal: ".", grouping: [3], thousands: " "}).format("012,.2f")(2), "0 000 002.00");
test.equal(d3.formatLocale({decimal: ".", grouping: [3], thousands: "/"}).format("012,.2f")(2), "0/000/002.00");
Expand Down

0 comments on commit 05c8ddb

Please sign in to comment.