• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/ruby
2#
3# generated_code.rb is in the same directory as this test.
4$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
5
6require 'test/unit'
7require 'objspace'
8require 'test_import_pb'
9
10$is_64bit = Google::Protobuf::Internal::SIZEOF_LONG == 8
11
12class MemoryTest < Test::Unit::TestCase
13  # 40 byte is the default object size. But the real size is dependent on many things
14  # such as arch etc, so there's no point trying to assert the exact return value here.
15  # We merely assert that we return something other than the default.
16  def test_objspace_memsize_of_arena
17    if $is_64bit
18      assert_operator 40, :<, ObjectSpace.memsize_of(Google::Protobuf::Internal::Arena.new)
19    end
20  end
21
22  def test_objspace_memsize_of_message
23    if $is_64bit
24      assert_operator 40, :<, ObjectSpace.memsize_of(FooBar::TestImportedMessage.new)
25    end
26  end
27
28  def test_objspace_memsize_of_map
29    if $is_64bit
30      assert_operator 40, :<, ObjectSpace.memsize_of(Google::Protobuf::Map.new(:string, :int32))
31    end
32  end
33end
34