Sha256: bb627ca1dbd57bd7da4b6a56a5726447720c00f34aadd3394213314fb2586fad
Contents?: true
Size: 1.27 KB
Versions: 5
Compression:
Stored size: 1.27 KB
Contents
require 'test/unit' require 'protobuf/message/message' require 'protobuf/message/enum' require 'test/proto/addressbook.pb' require 'test/proto/addressbook_base.pb' class EnumValueTest < Test::Unit::TestCase def test_enum_value e = Protobuf::EnumValue.new(Object, :name, 100) assert_kind_of(Protobuf::EnumValue, e) assert_equal(:name, e.name) assert_equal(100, e.value) assert_equal('name', e.to_s) assert_equal('name', "#{e}") assert(e == 100) assert(100 == e) assert_equal(101, e + 1) assert_equal(101, 1 + e) end def test_enum_field_and_enum_value phone_number = Tutorial::Person::PhoneNumber.new assert_kind_of(Protobuf::EnumValue, phone_number.type) assert_equal(Tutorial::Person::PhoneType::HOME, phone_number.type) phone_number.type = 1 assert_kind_of(Protobuf::EnumValue, phone_number.type) assert_equal(Tutorial::Person::PhoneType::HOME, phone_number.type) assert_equal(1, phone_number.type) phone_number.type = :HOME assert_equal(Tutorial::Person::PhoneType::HOME, phone_number.type) phone_number.type = 'HOME' assert_equal(Tutorial::Person::PhoneType::HOME, phone_number.type) assert_raise(TypeError) do phone_number.type = TutorialExt::Person::PhoneType::HOME end end end
Version data entries
5 entries across 5 versions & 1 rubygems