fedora-migrator /vendor/gems/facets-2.4.5/test/more/test_binreadable.rb

Language Ruby Lines 51
MD5 Hash fe7d20e77c9ed66f5b4bcebd5b5b6216 Estimated Cost $848 (why?)
Repository https://bitbucket.org/mediashelf/fedora-migrator View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Test for facets/binreadable.rb

require 'facets/binreadable.rb'
require 'test/unit'

class TC_ByteOrder < Test::Unit::TestCase

  include BinaryReader

  def test_equal
    assert_equal ByteOrder.little?, ByteOrder.little_endian?
    assert_equal ByteOrder.big?, ByteOrder.big_endian?
    assert_equal ByteOrder.network?, ByteOrder.big_endian?
    assert_equal ByteOrder.byte_order, ByteOrder.byteorder

    assert_equal ByteOrder::Big, ByteOrder::BigEndian
    assert_equal ByteOrder::Network, ByteOrder::BigEndian
    assert_equal ByteOrder::Little, ByteOrder::LittleEndian

    assert_equal ByteOrder.byte_order, ByteOrder::LittleEndian if ByteOrder.little?
    assert_equal ByteOrder.byte_order, ByteOrder::BigEndian if ByteOrder.big?
  end

  def test_uname_byteorder
    assert_equal(ByteOrder.little?, true) if `uname -m` =~ /i386/
  end

  def test_byteorder
    if ByteOrder.little?
      assert_equal "\x12\x34\x56\x78".unpack("L").first, 0x78563412
      assert_equal "\x78\x56\x34\x12".unpack("L").first, 0x12345678
      assert_equal [0x12345678].pack("L"), "\x78\x56\x34\x12"
      assert_equal [0x78563412].pack("L"), "\x12\x34\x56\x78"
    else
      assert_equal "\x12\x34\x56\x78".unpack("L").first, 0x12345678
      assert_equal "\x78\x56\x34\x12".unpack("L").first, 0x78563412
      assert_equal [0x12345678].pack("L"), "\x12\x34\x56\x78"
      assert_equal [0x78563412].pack("L"), "\x78\x56\x34\x12"
    end
  end

end

class TC_BinaryReader < Test::Unit::TestCase

  def test_todo
    assert(true)  # to do
  end

end
Back to Top