blob: 4a4ba0f7d9b70ab21f0769eab098a4d1c1cbc6ad [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +00001#
2# Licensed to the Apache Software Foundation (ASF) under one
3# or more contributor license agreements. See the NOTICE file
4# distributed with this work for additional information
5# regarding copyright ownership. The ASF licenses this file
6# to you under the Apache License, Version 2.0 (the
7# "License"); you may not use this file except in compliance
8# with the License. You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing,
13# software distributed under the License is distributed on an
14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15# KIND, either express or implied. See the License for the
16# specific language governing permissions and limitations
17# under the License.
18#
19
Kengo Sekicb4c31a2019-12-26 14:34:57 +090020use Test::More tests => 7;
21use Test::Exception;
T Jake Luciani1952e542009-02-01 04:47:30 +000022
23use strict;
24use warnings;
25
26use Data::Dumper;
27
28use Thrift::BinaryProtocol;
29use Thrift::MemoryBuffer;
30
31use ThriftTest::Types;
32
33
34my $transport = Thrift::MemoryBuffer->new();
35my $protocol = Thrift::BinaryProtocol->new($transport);
36
Kengo Sekicb4c31a2019-12-26 14:34:57 +090037throws_ok { $protocol->readByte } 'Thrift::TTransportException';
38
T Jake Luciani1952e542009-02-01 04:47:30 +000039my $a = ThriftTest::Xtruct->new();
40$a->i32_thing(10);
41$a->i64_thing(30);
42$a->string_thing('Hello, world!');
43$a->write($protocol);
44
45my $b = ThriftTest::Xtruct->new();
46$b->read($protocol);
47is($b->i32_thing, $a->i32_thing);
48is($b->i64_thing, $a->i64_thing);
49is($b->string_thing, $a->string_thing);
50
51$b->write($protocol);
52my $c = ThriftTest::Xtruct->new();
53$c->read($protocol);
54is($c->i32_thing, $a->i32_thing);
55is($c->i64_thing, $a->i64_thing);
56is($c->string_thing, $a->string_thing);