Bryan Duxbury | d815c21 | 2009-03-19 18:57:43 +0000 | [diff] [blame^] | 1 | require "spec/spec_helper" |
| 2 | require "lib/thrift/serializer" |
| 3 | |
| 4 | path, factory_class = ARGV |
| 5 | |
| 6 | factory = eval(factory_class).new |
| 7 | |
| 8 | deser = Thrift::Deserializer.new(factory) |
| 9 | |
| 10 | cpts = CompactProtoTestStruct.new |
| 11 | CompactProtoTestStruct.constants.each do |const| |
| 12 | cpts.instance_variable_set("@#{const}", nil) |
| 13 | end |
| 14 | |
| 15 | data = File.read(path) |
| 16 | |
| 17 | deser.deserialize(cpts, data) |
| 18 | |
| 19 | if cpts == Fixtures::COMPACT_PROTOCOL_TEST_STRUCT |
| 20 | puts "Object verified successfully!" |
| 21 | else |
| 22 | puts "Object failed verification! Expected #{Fixtures::COMPACT_PROTOCOL_TEST_STRUCT.inspect} but got #{cpts.inspect}" |
| 23 | |
| 24 | puts cpts.differences(Fixtures::COMPACT_PROTOCOL_TEST_STRUCT) |
| 25 | end |