blob: fdcdc82708f8a2c2d569c81860559c34156fbdc8 [file] [log] [blame]
David Reissbfc57a02009-03-30 20:46:37 +00001-module(test_membuffer).
2-export([t/0]).
3
4-include("thriftTest_types.hrl").
5
6test_data() ->
7 #xtruct{string_thing = <<"foobar">>,
8 byte_thing = 123,
9 i32_thing = 1234567,
10 i64_thing = 12345678900}.
11
12t1() ->
13 {ok, Transport} = thrift_memory_buffer:new(),
14 {ok, Protocol} = thrift_binary_protocol:new(Transport),
15 TestData = test_data(),
16 ok = thrift_protocol:write(Protocol,
17 {{struct, element(2, thriftTest_types:struct_info('xtruct'))},
18 TestData}),
19 {ok, Result} = thrift_protocol:read(Protocol,
20 {struct, element(2, thriftTest_types:struct_info('xtruct'))},
21 'xtruct'),
22
23 Result = TestData.
24
25
David Reiss233ace52009-03-30 20:46:47 +000026t2() ->
27 {ok, Transport} = thrift_memory_buffer:new(),
28 {ok, Protocol} = thrift_binary_protocol:new(Transport),
29 TestData = test_data(),
30 ok = thrift_protocol:write(Protocol,
31 {{struct, element(2, thriftTest_types:struct_info('xtruct'))},
32 TestData}),
33 {ok, Result} = thrift_protocol:read(Protocol,
34 {struct, element(2, thriftTest_types:struct_info('xtruct3'))},
35 'xtruct3'),
36
37 Result = #xtruct3{string_thing = TestData#xtruct.string_thing,
38 changed = undefined,
39 i32_thing = TestData#xtruct.i32_thing,
40 i64_thing = TestData#xtruct.i64_thing}.
41
42
David Reissbfc57a02009-03-30 20:46:37 +000043t() ->
David Reiss233ace52009-03-30 20:46:47 +000044 t1(),
45 t2().
David Reissbfc57a02009-03-30 20:46:37 +000046