Class: RandHashTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
RandTestHelpers
Defined in:
lib/rand.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from RandTestHelpers

#picker, #try_shuffling

Instance Method Details

#haObject



303
304
305
# File 'lib/rand.rb', line 303

def ha
  Hash[*(1..100).to_a]
end

#test_pickObject



307
308
309
# File 'lib/rand.rb', line 307

def test_pick
  assert true, picker(ha, ha.entries, :pick)
end

#test_pick!Object



311
312
313
314
# File 'lib/rand.rb', line 311

def test_pick!
  h = ha
  assert true, picker(h, ha.entries, :pick!) and h.empty? 
end

#test_pick_keyObject



316
317
318
# File 'lib/rand.rb', line 316

def test_pick_key
  assert true, picker(ha, ha.keys, :pick_key)
end

#test_pick_key!Object



320
321
322
323
# File 'lib/rand.rb', line 320

def test_pick_key!
  h = ha
  assert true, picker(h, ha.keys, :pick_key!) and h.empty?
end

#test_pick_valueObject



325
326
327
# File 'lib/rand.rb', line 325

def test_pick_value
  assert true, picker(ha, ha.values, :pick_value)
end

#test_pick_value!Object



329
330
331
332
# File 'lib/rand.rb', line 329

def test_pick_value!
  h = ha
  assert true, picker(h, ha.values, :pick_value!) and h.empty?
end

#test_shuffleObject



347
348
349
350
351
# File 'lib/rand.rb', line 347

def test_shuffle
  h = ha
  hs = try_shuffling(ha, h, :shuffle)
  assert true, hs != h and hs.entries.sort == h.entries.sort
end

#test_shuffle_hashObject



334
335
336
337
338
# File 'lib/rand.rb', line 334

def test_shuffle_hash
  h = ha
  hs = try_shuffling(ha, h, :shuffle_hash)
  assert true, hs != h and (hs.keys + hs.values).sort == (h.keys + h.values).sort
end

#test_shuffle_hash!Object



340
341
342
343
344
345
# File 'lib/rand.rb', line 340

def test_shuffle_hash!
  h = ha
  hs = ha
  try_shuffling(hs, h, :shuffle_hash!)
  assert true, hs != h and (hs.keys + hs.values).sort == (h.keys + h.values).sort
end