Permalink
Browse files

Adding test to detect mismatched currency symbols and code points

  • Loading branch information...
Cameron Dutro
Cameron Dutro committed Dec 13, 2012
1 parent 66ede66 commit 154d2c61a9679490831d8b98efe51ae29ca9beea
@@ -20,8 +20,9 @@ def for_code(currency_code, locale = :en)
result = {
:currency => currency_code,
:name => data[:one],
- :cldr_symbol => data[:symbol],
- :symbol => data[:symbol]
+ :cldr_symbol => data[:symbol] || currency_code.to_s,
+ :symbol => data[:symbol] || currency_code.to_s,
+ :code_points => (data[:symbol] || currency_code.to_s).unpack("U*")
}
result.merge!(symbol_data) if symbol_data
@@ -7,8 +7,8 @@
:symbol: LEK
:code_points:
- 76
- - 101
- - 107
+ - 69
+ - 75
:ANG:
:symbol: ƒ
:code_points:
@@ -44,7 +44,7 @@
:BGN:
:symbol: лв
:code_points:
- - 82
+ - 1083
- 1074
:BMD:
:symbol: $
@@ -304,7 +304,7 @@
:NOK:
:symbol: kr
:code_points:
- - 123
+ - 107
- 114
:NPR:
:symbol:
@@ -450,8 +450,8 @@
:VEF:
:symbol: Bs
:code_points:
- - 1083
- - 1074
+ - 66
+ - 115
:VND:
:symbol:
:code_points:
@@ -28,7 +28,7 @@
:name => "Peruvian nuevo sol",
:currency => :PEN,
:symbol => "S/.",
- :cldr_symbol => nil
+ :cldr_symbol => "PEN"
)
end
@@ -42,5 +42,12 @@
:cldr_symbol => "CA$"
)
end
+
+ it "verifies that all code_points values are equivalent to their corresponding symbols" do
+ Currencies.currency_codes.select do |code|
+ data = Currencies.for_code(code)
+ data[:code_points].pack("U*").should == data[:symbol]
+ end
+ end
end
end

0 comments on commit 154d2c6

Please sign in to comment.