Permalink
Browse files

Add tests for U::String#tr_s

  • Loading branch information...
1 parent b99903e commit 1c160a97bd5edaacaf0187ba2520432595c5da0e Nikolai Weibull committed Apr 3, 2013
Showing with 12 additions and 0 deletions.
  1. +12 −0 test/unit/u/string.rb
View
@@ -707,6 +707,18 @@
expect result.not.tainted? do 'abc'.u.tr('a', 'b'.taint) end
expect result.not.untrusted? do 'abc'.u.tr('a', 'b'.untrust) end
+ expect 'hïpö' do 'hëllö'.u.tr_s('ël', 'ïp') end
+ expect '*ë*ö' do 'hëllö'.u.tr_s('^aëiöu', '*') end
+ expect 'hal' do 'ibm'.u.tr_s('b-z', 'a-z') end
+ expect 'hal' do 'hal'.u.tr_s('a-z', 'a-z') end
+ expect true do a = 'hal'.u; a.tr_s('a-z', 'a-z').object_id == a.object_id end
+ expect result.tainted? do 'abc'.u.taint.tr_s('a', 'b') end
+ expect result.untrusted? do 'abc'.u.untrust.tr_s('a', 'b') end
+ expect result.not.tainted? do 'abc'.u.tr_s('a'.taint, 'b') end
+ expect result.not.untrusted? do 'abc'.u.tr_s('a'.untrust, 'b') end
+ expect result.not.tainted? do 'abc'.u.tr_s('a', 'b'.taint) end
+ expect result.not.untrusted? do 'abc'.u.tr_s('a', 'b'.untrust) end
+
expect [''.u, 'l'.u, ''.u] do 'hëllö'.u.partition(/l/u) end
expect [''.u, 'l'.u, ''.u] do 'hëllö'.u.partition('l'.u) end
expect [''.u, 'l'.u, ''.u] do 'hëllö'.u.partition('l') end

0 comments on commit 1c160a9

Please sign in to comment.