Class: RandStringTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- RandStringTest
- Includes:
- RandTestHelpers
- Defined in:
- lib/rand.rb
Overview
:nodoc:
Class Method Summary collapse
Instance Method Summary collapse
Methods included from RandTestHelpers
Class Method Details
.pick_tests(endings) ⇒ Object
358 359 360 361 362 363 364 365 |
# File 'lib/rand.rb', line 358 def self.pick_tests(endings) endings.each{|ending, compare_str_f| define_method("test_pick#{ending}"){ s = str assert true, picker(s, instance_eval(&compare_str_f), "pick#{ending}", s.size) } } end |
.pick_tests!(endings) ⇒ Object
367 368 369 370 371 372 373 374 |
# File 'lib/rand.rb', line 367 def self.pick_tests!(endings) endings.each{|ending, compare_str_f| define_method("test_pick#{ending}!"){ s = str assert true, picker(s, instance_eval(&compare_str_f), "pick#{ending}!", s.size) and s.empty? } } end |
Instance Method Details
#str ⇒ Object
376 377 378 |
# File 'lib/rand.rb', line 376 def str (("a".."z").to_s + "\n") * 10 end |
#test_shuffle ⇒ Object
380 381 382 383 384 |
# File 'lib/rand.rb', line 380 def test_shuffle s = str ss = try_shuffling(s, s.to_a, :shuffle) assert true, ss != s.to_a and ss.sort == s.to_a.sort end |
#test_shuffle_chars ⇒ Object
386 387 388 389 390 |
# File 'lib/rand.rb', line 386 def test_shuffle_chars s = str ss = try_shuffling(s, s.split(//), :shuffle_chars) assert true, ss != s and ss.split(//).sort == s.split(//).sort end |
#test_shuffle_chars! ⇒ Object
392 393 394 395 396 397 |
# File 'lib/rand.rb', line 392 def test_shuffle_chars! s = str ss = str try_shuffling(ss, s.split(//), :shuffle_chars!) assert true, ss != s and ss.split(//).sort == s.split(//).sort end |