Class: TestKyaniteStringChars
- Defined in
 - test/string/test_chars.rb
 
Tests for String
String Additions
- Kyanite definitions
 - Kyanite tests and examples
 - Usage
 - 
require 'kyanite/string'
 
Required from Facets String:
- shatter(re)
 - 
Breaks a string up into an array based on a regular expression. Similar to scan, but includes the matches.
 
clear / format text (collapse)
- - (Object) test_camelcase
 - - (Object) test_examples
 - - (Object) test_german_sz
 - - (Object) test_LANG_SPECIAL_CHARS
 - - (Object) test_minus_signs
 - - (Object) test_mysqlize
 - - (Object) test_newlines_and_nonprintables
 - - (Object) test_preserve
 - - (Object) test_reduce53_a
 - - (Object) test_reduce53_b
 - - (Object) test_reduce53_c
 - - (Object) test_reduce53_d
 - - (Object) test_reduce53_e
 - - (Object) test_reduce94_full
 - - (Object) test_spaces
 - - (Object) test_to_array_of_codepoints
 - - (Object) test_to_array_of_hex
 - - (Object) test_to_ascii_a
 - - (Object) test_to_ascii_b
 - - (Object) test_to_ascii_c
 - - (Object) test_to_ascii_e
 - - (Object) test_to_ascii_f
 - - (Object) test_to_ascii_s
 - - (Object) test_to_ascii_same_same
 - - (Object) test_to_ascii_zusammengesetzt
 - 
  
    
      - (Object) test_TR_EXTRA_CHARS 
    
    
  
  
    
---------------------------------------------------------------------------------------------------------------------------------.
 - - (Object) test_TR_FULL
 - - (Object) test_TR_FULL_TO_ASCII
 
Groß- und Kleinschreibung (collapse)
- - (Object) test_capitalize
 - - (Boolean) test_capitalized?
 - - (Object) test_downcase_upcase
 - - (Object) test_utf8_size
 
Instance Method Details
- (Object) test_camelcase
      288 289 290 291 292 293  | 
    
      # File 'test/string/test_chars.rb', line 288 def test_camelcase assert_equal 'TUKTUK', 'TukTuk'.reduce53 assert_equal 'TUKTUK', 'TukTuk'.reduce53(:camelcase => false) assert_equal 'TUK-TUK', 'TukTuk'.reduce53(:camelcase => true) assert_equal 'TUK-TUK', 'tukTuk'.reduce53(:camelcase => true) end  | 
  
- (Object) test_capitalize
      364 365 366 367 368 369 370 371 372  | 
    
      # File 'test/string/test_chars.rb', line 364 def test_capitalize test_down = 'äaoöuü' test_up = 'ÄAOÖUÜ' assert_equal 'Äaoöuü', 'äaoöuü'.capitalize assert_equal 'Àaoöuü', 'àaoöuü'.capitalize assert_equal 'Ăăaoöuü', 'ăăaoöuü'.capitalize assert_equal 'Öaoöuü', 'Öaoöuü'.capitalize end  | 
  
- (Boolean) test_capitalized?
      349 350 351 352 353 354 355 356 357 358 359 360 361  | 
    
      # File 'test/string/test_chars.rb', line 349 def test_capitalized? assert !'hallo'.capitalized? assert !'ħAllo'.capitalized? assert !'ĥÅllo'.capitalized? assert !'ätsch'.capitalized? assert 'Hallo'.capitalized? assert 'ĤAllo'.capitalized? assert 'ĦAllo'.capitalized? assert 'Ætsch Ruby scheißt auf Unicode'.capitalized? assert 'Ūbel'.capitalized? assert 'Øzi ist moderner'.capitalized? end  | 
  
- (Object) test_downcase_upcase
      318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346  | 
    
      # File 'test/string/test_chars.rb', line 318 def test_downcase_upcase test_down = 'àáâăäãāåạąảấầắằабćĉčçċцчďðđдèéêěĕëēėęếеэфĝğġģгĥħхìíîĭïĩīıįийĵюяķкĺľłļŀлмńňñņŋнòóôŏöõōøőơœопŕřŗрśŝšşсшщţťŧþтùúûŭüũūůűųưувŵýŷÿźżžжз' test_up = 'ÀÁÂĂÄÃĀÅẠĄẢẤẦẮẰАБĆĈČÇĊЦЧĎÐĐДÈÉÊĚĔËĒĖĘẾЕЭФĜĞĠĢГĤĦХÌÍÎĬÏĨĪİĮИЙĴЮЯĶКĹĽŁĻĿЛМŃŇÑŅŊНÒÓÔŎÖÕŌØŐƠŒОПŔŘŖРŚŜŠŞСШЩŢŤŦÞТÙÚÛŬÜŨŪŮŰŲƯУВŴÝŶŸŹŻŽЖЗ' # Bescheid sagen, sobald Ruby oder ActiveSupport von sich aus funktionieren assert_not_equal test_down, test_up.downcase assert_not_equal test_down, test_up.downcase assert_equal test_down, test_up.downcase2 assert_equal test_down, test_up.upcase2.downcase2 assert_equal test_down, test_up.upcase2.downcase2.upcase2.downcase2 assert_equal test_up, test_down.upcase2 assert_equal test_up, test_down.downcase2.upcase2 assert_equal test_up, test_down.downcase2.upcase2.downcase2.upcase2 teststrings = ['ÄÖÜ', 'äöü','ÄÖÜß', 'äöüß',] teststrings.each do |t| assert_equal t.upcase2, t.downcase2.upcase2 assert_equal t.downcase2, t.upcase2.downcase2 end assert_equal 'ÄÖÜ', 'äöü'.upcase2 assert_equal 'ÄÖÜ', 'äöü'.upcase2.upcase2 assert_equal 'ÄÖÜß', 'äöüß'.upcase2.upcase2 assert_equal 'äöü', 'ÄÖÜ'.downcase2 assert_equal 'äöü', 'ÄÖÜ'.downcase2.downcase2 assert_equal 'äöüß', 'ÄÖÜß'.downcase2.downcase2 end  | 
  
- (Object) test_examples
      199 200 201 202 203 204 205  | 
    
      # File 'test/string/test_chars.rb', line 199 def test_examples assert_equal "Celine hoeren", "Céline hören".reduce assert_equal "AeOeUeaeoeuess", "ÄÖÜäöüß".reduce assert_equal "Celine hören 10EUR", "Céline hören 10€".reduce( :preserve => "ÄÖÜäöüß") assert_equal "Celine hören 10€", "Céline hören 10€".reduce( :preserve => "ÄÖÜäöü߀", :fast => true) assert_equal "AOUaous", "ÄÖÜäöü߀".reduce( :fast => true ) end  | 
  
- (Object) test_german_sz
      274 275 276 277 278 279 280 281 282 283 284 285  | 
    
      # File 'test/string/test_chars.rb', line 274 def test_german_sz assert_equal 'SCHEIßE', 'Scheiße'.upcase2 assert_equal 'SCHEIßE', 'scheiße'.upcase2 assert_equal 'scheiße', 'Scheiße'.downcase2 assert_equal 'scheiße', 'SCHEIßE'.downcase2 assert_equal 'Scheise', 'Scheiße'.reduce94 assert_equal 'SCHEIsE', 'Scheiße'.reduce53 assert_equal 'SCHEIZE', 'Scheiße'.reduce53(:german_sz => 'z') assert_equal 'SCHEIZE', 'Scheiße'.reduce53(:german_sz => 'Z') assert_equal 'SCHEISSE', 'Scheiße'.reduce53(:german_sz => 'SS') assert_equal 'Scheiß Arsche', 'Scheiß Ärsche'.reduce94(:preserve => 'ß') end  | 
  
- (Object) test_LANG_SPECIAL_CHARS
      161 162 163 164 165 166  | 
    
      # File 'test/string/test_chars.rb', line 161 def test_LANG_SPECIAL_CHARS LANG_SPECIAL_CHARS .each do | lang, (full, reduced) | #see lang, full, reduced, full.reduce, full.reduce94 assert_equal reduced, full.reduce end end  | 
  
- (Object) test_minus_signs
      175 176 177 178 179  | 
    
      # File 'test/string/test_chars.rb', line 175 def test_minus_signs minus = "\u00ac\u2212\u2010\u2011\u2012\u2013\u2014\u2015\u2500" assert_equal minus.reduce, "-" * minus.length #assert_equal spaces.reduce94, " " * spaces.length end  | 
  
- (Object) test_mysqlize
      297 298 299 300 301 302 303 304 305 306 307  | 
    
      # File 'test/string/test_chars.rb', line 297 def test_mysqlize test0 = 'aaoouuß' test1 = 'aäoöuüss' test2 = 'AÄOÖUÜSS' test3 = 'AAOOUUß' assert_equal test0, test0.mysqlize assert_equal test0, test1.mysqlize assert_equal test0, test2.mysqlize assert_equal test0, test3.mysqlize end  | 
  
- (Object) test_newlines_and_nonprintables
      208 209 210 211 212 213  | 
    
      # File 'test/string/test_chars.rb', line 208 def test_newlines_and_nonprintables test = "Céli\x00ne\nhöre\x0c\x0e\x0fn" assert_equal "Celine\nhören", test.reduce( :preserve => "ÄÖÜäöüß") assert_equal "Celine\nhoeren", test.reduce assert_equal "Celine\nhoren", test.reduce(:fast => true ) end  | 
  
- (Object) test_preserve
      182 183 184 185 186 187 188 189 190 191 192 193 194 195  | 
    
      # File 'test/string/test_chars.rb', line 182 def test_preserve # 0123456789012345678901234567890123456789 test = "ßàáâăäãāāāåạąæảấầắằÀÁÂĂÄÃĀÅẠĄÆẢẤẦẮẰćĉčçċĆĈČÇĊďðđĎÐĐèéêěĕëēėęếÈÉÊĚĔËĒĖĘẾĝğġģĜĞĠĢĥħĤĦìíîĭïĩīıįijÌÍÎĬÏĨĪİĮIJĵĴķĶĺľłļŀĹĽŁĻĿńňñņʼnŋŃŇÑŅŊòóôŏöõōøőơœÒÓÔŎÖÕŌØŐƠŒŕřŗŔŘŖśŝšßşŚŜŠŞţťŧþŢŤŦÞùúûŭüũūůűųưÙÚÛŬÜŨŪŮŰŲƯŵŴýŷÿÝŶŸźżžŹŻŽ" belassen = test[10..27] exp = "ssaaaaaeaaaaåạąæảấầắằÀÁÂĂÄÃĀÅẠAAEAAAAAccccchCCCCChdddDDDeeeeeeeeeeEEEEEEEEEEggghgGGGhGhhHHiiiiiiiiiijIIIIIIIIIIJjJkKlllllLLLLLnnnnnnjNNNNNJoooooeooooooeOOOOOeOOOOOOErrrRRRssshsssSSShSttttTTTTuuuuueuuuuuuUUUUUeUUUUUUwWyyyYYYzzzhZZZh" assert_equal exp, test.reduce(:preserve => belassen) assert_raise ArgumentError do belassen = test[10..28] test.reduce(:preserve => belassen) end test = "Háâaäãaållo\nWelt" assert_equal "Haaaäaaallo\nWelt", test.reduce( :preserve =>"äöüßÄÖÜ" ) end  | 
  
- (Object) test_reduce53_a
      243 244 245 246 247  | 
    
      # File 'test/string/test_chars.rb', line 243 def test_reduce53_a full = ' ŕřŗŔŘŖśŝšßşŚŜ ŠŞţťŧþŢŤŦÞùúûŭ üũūůűųưÙÚÛ ÜŨŪŮŰŲƯŵ ŴýŷÿÝŶŸźżžŹŻŽ ' reduced = 'rrrrrrsssssss-ssttttttttuuuu-uuuuuuuuuu-uuuuuuuw-wyyyyyyzzzzzz' assert_equal reduced, full.reduce53 end  | 
  
- (Object) test_reduce53_b
      249 250 251 252 253  | 
    
      # File 'test/string/test_chars.rb', line 249 def test_reduce53_b full = " h A-- $%$%--llo §-$\n$^° " reduced = 'H-A-LLO' assert_equal reduced, full.reduce53 end  | 
  
- (Object) test_reduce53_c
      255 256 257 258 259  | 
    
      # File 'test/string/test_chars.rb', line 255 def test_reduce53_c full = " h A-- $%Ѥ%--llo\n §-$\n$^° " reduced = 'H-A-LLO' assert_equal reduced, full.reduce53 end  | 
  
- (Object) test_reduce53_d
      261 262 263 264 265  | 
    
      # File 'test/string/test_chars.rb', line 261 def test_reduce53_d full = " h Ä-- $%Ѥ%--llo\n §-$\n$^° " reduced = 'H-a-LLO' assert_equal reduced, full.reduce53 end  | 
  
- (Object) test_reduce53_e
      267 268 269 270 271  | 
    
      # File 'test/string/test_chars.rb', line 267 def test_reduce53_e full = " h ä-- $%Ѥ%--llo\n §-$\n$^° " reduced = 'H-a-LLO' assert_equal reduced, full.reduce53 end  | 
  
- (Object) test_reduce94_full
      218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240  | 
    
      # File 'test/string/test_chars.rb', line 218 def test_reduce94_full full = <<ENDOFSTRING àáâăäãāåạąảấầắằÀÁÂĂÄÃĀÅẠĄẢẤẦẮẰćĉčçċĆĈČÇĊďðđĎÐĐèéêěĕëēėęếÈÉÊĚĔËĒĖĘẾĝğġģĜĞĠĢĥħĤĦìíîĭïĩīıįÌÍÎĬÏĨĪİĮĵĴķĶĺľłļŀĹĽŁĻĿńňñņʼnŋŃŇÑŅŊòóôŏöõōøőơœÒÓÔŎÖÕŌØŐƠŒŕřŗŔŘŖśŝšßşŚŜŠŞţťŧþŢŤŦÞùúûŭüũūůűųưÙÚÛŬÜŨŪŮŰŲƯŵŴýŷÿÝŶŸźżžŹŻŽ ENDOFSTRING reduced = <<ENDOFSTRING aaaaaaaaaaaaaaaAAAAAAAAAAAAAAAcccccCCCCCdddDDDeeeeeeeeeeEEEEEEEEEEggggGGGGhhHHiiiiiiiiiIIIIIIIIIjJkKlllllLLLLLnnnnnnNNNNNoooooooooooOOOOOOOOOOOrrrRRRsssssSSSSttttTTTTuuuuuuuuuuuUUUUUUUUUUUwWyyyYYYzzzZZZ ENDOFSTRING full = full.chomp reduced = reduced.chomp assert_equal reduced, full.reduce94 # require 'perception' # rawlog "\n----------------------------------------------------------\n\n" # rawlog 'full= ' # rawlog full # rawlog "\n" # rawlog 'reduced= ' # rawlog reduced # rawlog "\n" end  | 
  
- (Object) test_spaces
      168 169 170 171 172  | 
    
      # File 'test/string/test_chars.rb', line 168 def test_spaces spaces = "\u0020\u00a0\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u202f\u205f\u3000\u2420\u2423" assert_equal spaces.reduce, " " * spaces.length assert_equal spaces.reduce94, " " * spaces.length end  | 
  
- (Object) test_to_array_of_codepoints
      69 70 71 72 73  | 
    
      # File 'test/string/test_chars.rb', line 69 def test_to_array_of_codepoints test = "H¿llÛ" assert_equal [72, 191, 108, 108, 219], test.to_array_of_codepoints assert_equal test, [72, 191, 108, 108, 219].to_s_utf8 end  | 
  
- (Object) test_to_array_of_hex
      75 76 77 78 79 80 81 82  | 
    
      # File 'test/string/test_chars.rb', line 75 def test_to_array_of_hex euro = "\u20ac" ffi = "\uFB03" ix = "\u2168" high5 = "\u2075" all = euro + ffi + ix + high5 assert_equal ["20ac", "fb03", "2168", "2075"], all.to_array_of_hex end  | 
  
- (Object) test_to_ascii_a
      86 87 88 89 90 91  | 
    
      # File 'test/string/test_chars.rb', line 86 def test_to_ascii_a full = 'ªàáâăãāåạąảấầắằÀÁÂĂÃĀÅẠĄẢẤẦẮẰ' reduced = 'aaaaaaaaaaaaaaaAAAAAAAAAAAAAA' assert_equal reduced, full.reduce94 assert_equal reduced, full.reduce end  | 
  
- (Object) test_to_ascii_b
      93 94 95 96 97 98 99  | 
    
      # File 'test/string/test_chars.rb', line 93 def test_to_ascii_b full = 'ćĉčçċĆĈČÇĊďĎèéêěĕëēėęếÈÉÊĚĔËĒĖĘẾ' reduced1 = 'cccccCCCCCdDeeeeeeeeeeEEEEEEEEEE' reduced2 = 'ccccchCCCCChdDeeeeeeeeeeEEEEEEEEEE' assert_equal reduced1, full.reduce94 assert_equal reduced2, full.reduce end  | 
  
- (Object) test_to_ascii_c
      101 102 103 104 105 106 107  | 
    
      # File 'test/string/test_chars.rb', line 101 def test_to_ascii_c full = 'ĝğġģĜĞĠĢĥĤìíîĭïĩīįÌÍÎĬÏĨĪİĮĵĴķĶĺľļŀĹĽĻĿ' reduced1 = 'ggggGGGGhHiiiiiiiiIIIIIIIIIjJkKllllLLLL' reduced2 = 'ggghgGGGhGhHiiiiiiiiIIIIIIIIIjJkKllllLLLL' assert_equal reduced1, full.reduce94 assert_equal reduced2, full.reduce end  | 
  
- (Object) test_to_ascii_e
      109 110 111 112 113 114  | 
    
      # File 'test/string/test_chars.rb', line 109 def test_to_ascii_e full = 'ńňñņʼnŃŇÑŅòóôŏõōőơÒÓÔŎÕŌŐƠ' reduced = 'nnnnnNNNNooooooooOOOOOOOO' assert_equal reduced, full.reduce94 assert_equal reduced, full.reduce end  | 
  
- (Object) test_to_ascii_f
      116 117 118 119 120 121 122  | 
    
      # File 'test/string/test_chars.rb', line 116 def test_to_ascii_f full = 'ŕřŗŔŘŖśŝšşŚŜŠŞţťŢŤùúûŭũūůűųưÙÚÛŬŨŪŮŰŲƯŵŴýŷÿÝŶŸźżžŹŻŽ' reduced1 = 'rrrRRRssssSSSSttTTuuuuuuuuuuUUUUUUUUUUwWyyyYYYzzzZZZ' reduced2 = 'rrrRRRssshsSSShSttTTuuuuuuuuuuUUUUUUUUUUwWyyyYYYzzzhZZZh' assert_equal reduced1, full.reduce94 assert_equal reduced2, full.reduce end  | 
  
- (Object) test_to_ascii_s
      149 150 151 152 153 154 155 156 157 158 159  | 
    
      # File 'test/string/test_chars.rb', line 149 def test_to_ascii_s ffi = "\uFB03" ix = "\u2168" high23="²³" high5 = "\u2075" full = ffi + ix + high23 + high5 + "€ßÖÜÄöüä" reduced1 = "sOUAoua" reduced2 = "ffiIX235EURssOeUeAeoeueae" assert_equal reduced1, full.reduce94 assert_equal reduced2, full.reduce end  | 
  
- (Object) test_to_ascii_same_same
      130 131 132 133 134 135 136 137 138 139  | 
    
      # File 'test/string/test_chars.rb', line 130 def test_to_ascii_same_same same_same = '^!"$%&/()=?@*+~#<>|,;:.-_ {[]}\\' assert_equal same_same, same_same.reduce same_same = "'0123456789" assert_equal same_same, same_same.reduce same_same = 'abcdefghijklmnopqrstuvwxyz' assert_equal same_same, same_same.reduce same_same = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' assert_equal same_same, same_same.reduce end  | 
  
- (Object) test_to_ascii_zusammengesetzt
      124 125 126 127 128  | 
    
      # File 'test/string/test_chars.rb', line 124 def test_to_ascii_zusammengesetzt full = 'ijIJſ…' reduced = 'ijIJs...' assert_equal reduced, full.reduce end  | 
  
- (Object) test_TR_EXTRA_CHARS
      22 23 24 25 26 27 28 29 30 31 32 33  | 
    
      # File 'test/string/test_chars.rb', line 22 def test_TR_EXTRA_CHARS startline = 23 # Zeilennummer in der TR_EXTRA_CHARS definiert wird i = 0 all = "" TR_EXTRA_CHARS.each do | a | c = a[0].to_s[7] all += c assert_equal 0, all.to_a.to_set.size-i-1, "TR_EXTRA_CHARS: Dup in Zeile #{i+startline} Zeichen #{c}" #assert c.to_array_of_codepoints[0] > 127, "TR_EXTRA_CHARS: Trivialität in Zeile #{i+startline} Zeichen #{c}" i+=1 end end  | 
  
- (Object) test_TR_FULL
      36 37 38 39 40 41 42 43 44 45 46 47 48 49 50  | 
    
      # File 'test/string/test_chars.rb', line 36 def test_TR_FULL assert_equal TR_FULL.length, TR_REDUCED.length i = 0 all = "" TR_FULL.each_char do | c | r = TR_REDUCED[i] all += c #see "Zeichen Nr. #{i} Zeichen #{c} >> #{r}" assert_equal 0, all.to_a.to_set.size-i-1, "TR_FULL: Dup in Zeichen Nr. #{i} Zeichen #{c} >> #{r}" assert c.to_array_of_codepoints[0] > 127, "TR_FULL: Trivialität in Zeichen Nr. #{i} Zeichen #{c} >> #{r}" assert r.to_array_of_codepoints[0] <= 127, "TR_FULL: Zeichen Nr. #{i} Zeichen #{c} >> #{r} wird nicht in ASCII umgesetzt" assert_equal c.reduce94, c.reduce[0] i+=1 end end  | 
  
- (Object) test_TR_FULL_TO_ASCII
      53 54 55 56 57 58 59 60 61 62 63 64 65 66  | 
    
      # File 'test/string/test_chars.rb', line 53 def test_TR_FULL_TO_ASCII assert_equal TR_FULL_TO_ASCII.length, TR_REDUCED_TO_ASCII.length i = 0 all = "" TR_FULL_TO_ASCII.each_char do | c | r = TR_REDUCED_TO_ASCII[i] all += c #see "Zeichen Nr. #{i} Zeichen #{c} >> #{r}" assert_equal 0, all.to_a.to_set.size-i-1, "TR_FULL_TO_ASCII: Dup in Zeichen Nr. #{i} Zeichen #{c} >> #{r}" assert c.to_array_of_codepoints[0] > 127, "TR_FULL_TO_ASCII: Trivialität in Zeichen Nr. #{i} Zeichen #{c} >> #{r}" assert r.to_array_of_codepoints[0] <= 127, "TR_FULL_TO_ASCII: Zeichen Nr. #{i} Zeichen #{c} >> #{r} wird nicht in ASCII umgesetzt" i+=1 end end  | 
  
- (Object) test_utf8_size
      375 376 377  | 
    
      # File 'test/string/test_chars.rb', line 375 def test_utf8_size assert_equal 3, 'Özi'.size end  |