THRIFT-1151 - catch some serialization errors
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1137131 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/erl/src/Thrift1151.thrift b/test/erl/src/Thrift1151.thrift
new file mode 100644
index 0000000..6f934a7
--- /dev/null
+++ b/test/erl/src/Thrift1151.thrift
@@ -0,0 +1,3 @@
+struct StructA { 1: i16 x; }
+struct StructB { 1: i32 x; }
+struct StructC { 1: StructA x; }
diff --git a/test/erl/src/test_thrift_1151.erl b/test/erl/src/test_thrift_1151.erl
new file mode 100644
index 0000000..c50ddee
--- /dev/null
+++ b/test/erl/src/test_thrift_1151.erl
@@ -0,0 +1,19 @@
+-module(test_thrift_1151).
+
+-include("thrift1151_types.hrl").
+
+-export([t/0, t1/0]).
+
+t() ->
+ S1 = #structC{x=#structB{x=1}},
+ {ok, Transport} = thrift_memory_buffer:new(),
+ {ok, Protocol} = thrift_binary_protocol:new(Transport),
+ thrift_protocol:write(Protocol,
+ {{struct, element(2, thrift1151_types:struct_info('structC'))}, S1}).
+
+t1() ->
+ S2 = #structC{x=#structA{x="1"}},
+ {ok, Transport} = thrift_memory_buffer:new(),
+ {ok, Protocol} = thrift_binary_protocol:new(Transport),
+ thrift_protocol:write(Protocol,
+ {{struct, element(2, thrift1151_types:struct_info('structC'))}, S2}).