blob: 1adb5c74e6b008ca04a1665809f7192f23112bd9 [file] [log] [blame]
Mark Slee02d1edc2007-03-07 05:17:25 +00001#!/usr/bin/env ruby
Mark Slee6d7d5952007-01-27 01:44:22 +00002
3$:.push('gen-rb')
Mark Slee157d9f72007-02-07 06:03:53 +00004$:.push('../../lib/rb/lib')
Mark Slee6d7d5952007-01-27 01:44:22 +00005
6require 'thrift/transport/tsocket'
7require 'thrift/protocol/tbinaryprotocol'
8require 'ThriftTest'
9
10s = TSocket.new('localhost', 9090)
11p = TBinaryProtocol.new(s)
Mark Slee58dfb4f2007-07-06 02:45:25 +000012c = Thrift::Test::ThriftTest::Client.new(p)
Mark Slee6d7d5952007-01-27 01:44:22 +000013
14s.open()
15
16puts c.testString('string')
17puts c.testByte(8)
18puts c.testByte(-8)
19puts c.testI32(32)
20puts c.testI32(-32)
21puts c.testI64(64)
22puts c.testI64(-64)
23puts c.testDouble(3.14)
24puts c.testDouble(-3.14)
25puts c.testMap({1 => 1, 2 => 2, 3 => 3})
26puts c.testList([1,2,3,4,5])
27puts c.testSet({1 => true, 2 => true, 3 => true})
Mark Slee58dfb4f2007-07-06 02:45:25 +000028struct = Thrift::Test::Xtruct.new({'string_thing' => 'hi!', 'i32_thing' => 4 })
Mark Slee477a5802007-06-30 01:18:12 +000029puts c.testStruct(struct)
Mark Slee58dfb4f2007-07-06 02:45:25 +000030puts c.testNest(Thrift::Test::Xtruct2.new({'struct_thing' => struct, 'i32_thing' => 10}))
31insane = Thrift::Test::Insanity.new({'userMap' => { Thrift::Test::Numberz::ONE => 44 }, 'xtructs' => [struct, Thrift::Test::Xtruct.new({'string_thing' => 'hi again', 'i32_thing' => 12})]})
32puts c.testInsanity(insane)
33puts c.testMapMap(4).inspect
Mark Slee477a5802007-06-30 01:18:12 +000034
Mark Slee6d7d5952007-01-27 01:44:22 +000035s.close()
36
37