Sha256: c0713ddf700069da944d42b2b1dd699d5153efebaa60432307cd8d325bf56de8
Contents?: true
Size: 899 Bytes
Versions: 1
Compression:
Stored size: 899 Bytes
Contents
#!/usr/bin/env ruby # swap.rb # Array#swap! unit tests require 'test/unit' require 'pathname' dir = Pathname.new(File.expand_path(__FILE__)).realpath require File.join(File.dirname(dir.to_s), '../lib/rex') class SwapTests < Test::Unit::TestCase def test_swap_nil expected = [nil,nil] actual = nil assert_nothing_raised do actual = [] actual.swap!(0,1) end assert_not_nil(actual) assert_instance_of(Array, actual) assert_equal(false, actual.empty?) assert_equal(2, actual.size) assert_equal(expected, actual) end def test_swap_321 expected = [3,2,1] actual = nil assert_nothing_raised do actual = [1,2,3] actual.swap!(0,2) end assert_not_nil(actual) assert_instance_of(Array, actual) assert_equal(false, actual.empty?) assert_equal(3, actual.size) assert_equal(expected, actual) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rex-0.0.4 | test/swap.rb |