Skip to content

Commit 468836b

Browse files
committed
Add splitted stream testing of Unpacker related to issue #59.
1 parent 1405f01 commit 468836b

17 files changed

Lines changed: 19410 additions & 3964 deletions

test/MsgPack.UnitTest.Mono/MsgPack.UnitTest.Mono.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,9 @@
989989
<Compile Include="..\MsgPack.UnitTest\Serialization\_SetUpFixture.cs">
990990
<Link>Serialization\_SetUpFixture.cs</Link>
991991
</Compile>
992+
<Compile Include="..\MsgPack.UnitTest\SplittingStream.cs">
993+
<Link>SplittingStream.cs</Link>
994+
</Compile>
992995
<Compile Include="..\MsgPack.UnitTest\SubtreeUnpackerTest.cs">
993996
<Link>SubtreeUnpackerTest.cs</Link>
994997
</Compile>

test/MsgPack.UnitTest.Net35/MsgPack.UnitTest.Net35.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@
322322
<Compile Include="..\MsgPack.UnitTest\Serialization\_SetUpFixture.cs">
323323
<Link>Serialization\_SetUpFixture.cs</Link>
324324
</Compile>
325+
<Compile Include="..\MsgPack.UnitTest\SplittingStream.cs">
326+
<Link>SplittingStream.cs</Link>
327+
</Compile>
325328
<Compile Include="..\MsgPack.UnitTest\SubtreeUnpackerTest.cs">
326329
<Link>SubtreeUnpackerTest.cs</Link>
327330
</Compile>

test/MsgPack.UnitTest.Silverlight.WindowsPhone/MsgPack.UnitTest.Silverlight.WindowsPhone.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,9 @@
327327
<Compile Include="..\MsgPack.UnitTest\Serialization\_SetUpFixture.cs">
328328
<Link>Serialization\_SetUpFixture.cs</Link>
329329
</Compile>
330+
<Compile Include="..\MsgPack.UnitTest\SplittingStream.cs">
331+
<Link>SplittingStream.cs</Link>
332+
</Compile>
330333
<Compile Include="..\MsgPack.UnitTest\SubtreeUnpackerTest.cs">
331334
<Link>SubtreeUnpackerTest.cs</Link>
332335
</Compile>

test/MsgPack.UnitTest.WinRT/MsgPack.UnitTest.WinRT.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@
367367
<Compile Include="..\MsgPack.UnitTest\Serialization\_SetUpFixture.cs">
368368
<Link>Serialization\_SetUpFixture.cs</Link>
369369
</Compile>
370+
<Compile Include="..\MsgPack.UnitTest\SplittingStream.cs">
371+
<Link>SplittingStream.cs</Link>
372+
</Compile>
370373
<Compile Include="..\MsgPack.UnitTest\SubtreeUnpackerTest.cs">
371374
<Link>SubtreeUnpackerTest.cs</Link>
372375
</Compile>

test/MsgPack.UnitTest.Xamarin.Android/MsgPack.UnitTest.Xamarin.Android.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,9 @@
955955
<Compile Include="..\MsgPack.UnitTest\Serialization\VersioningTest.cs">
956956
<Link>Serialization\VersioningTest.cs</Link>
957957
</Compile>
958+
<Compile Include="..\MsgPack.UnitTest\SplittingStream.cs">
959+
<Link>SplittingStream.cs</Link>
960+
</Compile>
958961
<Compile Include="..\MsgPack.UnitTest\SubtreeUnpackerTest.cs">
959962
<Link>SubtreeUnpackerTest.cs</Link>
960963
</Compile>

test/MsgPack.UnitTest.Xamarin.iOS/MsgPack.UnitTest.Xamarin.iOS.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,9 @@
992992
<Compile Include="..\MsgPack.UnitTest\Serialization\VersioningTest.cs">
993993
<Link>Serialization\VersioningTest.cs</Link>
994994
</Compile>
995+
<Compile Include="..\MsgPack.UnitTest\SplittingStream.cs">
996+
<Link>SplittingStream.cs</Link>
997+
</Compile>
995998
<Compile Include="..\MsgPack.UnitTest\SubtreeUnpackerTest.cs">
996999
<Link>SubtreeUnpackerTest.cs</Link>
9971000
</Compile>

test/MsgPack.UnitTest/MsgPack.UnitTest.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,7 @@
10101010
<AutoGen>True</AutoGen>
10111011
<DesignTime>True</DesignTime>
10121012
</Compile>
1013+
<Compile Include="SplittingStream.cs" />
10131014
<Compile Include="SubtreeUnpackerTest.cs" />
10141015
<Compile Include="UnpackerTest.Ext.cs">
10151016
<AutoGen>True</AutoGen>

test/MsgPack.UnitTest/PackUnpackTest.Scalar.cs

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ private static void TestByte( Byte value )
6363
Assert.AreEqual( value, ( Byte )mpo );
6464
Assert.AreEqual( value, mpo.AsByte() );
6565
}
66+
67+
[Test]
68+
public void TestByte_Splitted()
69+
{
70+
var value = Byte.MaxValue;
71+
using( var output = new MemoryStream() )
72+
{
73+
Packer.Create( output ).Pack( value );
74+
output.Position = 0;
75+
using( var splitted = new SplittingStream( output ) )
76+
{
77+
var mpo = Unpacking.UnpackObject( splitted );
78+
Assert.AreEqual( value, ( Byte )mpo );
79+
Assert.AreEqual( value, mpo.AsByte() );
80+
}
81+
}
82+
}
6683

6784
[Test]
6885
public void TestSByte()
@@ -90,6 +107,23 @@ private static void TestSByte( SByte value )
90107
Assert.AreEqual( value, ( SByte )mpo );
91108
Assert.AreEqual( value, mpo.AsSByte() );
92109
}
110+
111+
[Test]
112+
public void TestSByte_Splitted()
113+
{
114+
var value = SByte.MaxValue;
115+
using( var output = new MemoryStream() )
116+
{
117+
Packer.Create( output ).Pack( value );
118+
output.Position = 0;
119+
using( var splitted = new SplittingStream( output ) )
120+
{
121+
var mpo = Unpacking.UnpackObject( splitted );
122+
Assert.AreEqual( value, ( SByte )mpo );
123+
Assert.AreEqual( value, mpo.AsSByte() );
124+
}
125+
}
126+
}
93127

94128
[Test]
95129
public void TestInt16()
@@ -117,6 +151,23 @@ private static void TestInt16( Int16 value )
117151
Assert.AreEqual( value, ( Int16 )mpo );
118152
Assert.AreEqual( value, mpo.AsInt16() );
119153
}
154+
155+
[Test]
156+
public void TestInt16_Splitted()
157+
{
158+
var value = Int16.MaxValue;
159+
using( var output = new MemoryStream() )
160+
{
161+
Packer.Create( output ).Pack( value );
162+
output.Position = 0;
163+
using( var splitted = new SplittingStream( output ) )
164+
{
165+
var mpo = Unpacking.UnpackObject( splitted );
166+
Assert.AreEqual( value, ( Int16 )mpo );
167+
Assert.AreEqual( value, mpo.AsInt16() );
168+
}
169+
}
170+
}
120171

121172
[Test]
122173
public void TestUInt16()
@@ -143,6 +194,23 @@ private static void TestUInt16( UInt16 value )
143194
Assert.AreEqual( value, ( UInt16 )mpo );
144195
Assert.AreEqual( value, mpo.AsUInt16() );
145196
}
197+
198+
[Test]
199+
public void TestUInt16_Splitted()
200+
{
201+
var value = UInt16.MaxValue;
202+
using( var output = new MemoryStream() )
203+
{
204+
Packer.Create( output ).Pack( value );
205+
output.Position = 0;
206+
using( var splitted = new SplittingStream( output ) )
207+
{
208+
var mpo = Unpacking.UnpackObject( splitted );
209+
Assert.AreEqual( value, ( UInt16 )mpo );
210+
Assert.AreEqual( value, mpo.AsUInt16() );
211+
}
212+
}
213+
}
146214

147215
[Test]
148216
public void TestInt32()
@@ -170,6 +238,23 @@ private static void TestInt32( Int32 value )
170238
Assert.AreEqual( value, ( Int32 )mpo );
171239
Assert.AreEqual( value, mpo.AsInt32() );
172240
}
241+
242+
[Test]
243+
public void TestInt32_Splitted()
244+
{
245+
var value = Int32.MaxValue;
246+
using( var output = new MemoryStream() )
247+
{
248+
Packer.Create( output ).Pack( value );
249+
output.Position = 0;
250+
using( var splitted = new SplittingStream( output ) )
251+
{
252+
var mpo = Unpacking.UnpackObject( splitted );
253+
Assert.AreEqual( value, ( Int32 )mpo );
254+
Assert.AreEqual( value, mpo.AsInt32() );
255+
}
256+
}
257+
}
173258

174259
[Test]
175260
public void TestUInt32()
@@ -196,6 +281,23 @@ private static void TestUInt32( UInt32 value )
196281
Assert.AreEqual( value, ( UInt32 )mpo );
197282
Assert.AreEqual( value, mpo.AsUInt32() );
198283
}
284+
285+
[Test]
286+
public void TestUInt32_Splitted()
287+
{
288+
var value = UInt32.MaxValue;
289+
using( var output = new MemoryStream() )
290+
{
291+
Packer.Create( output ).Pack( value );
292+
output.Position = 0;
293+
using( var splitted = new SplittingStream( output ) )
294+
{
295+
var mpo = Unpacking.UnpackObject( splitted );
296+
Assert.AreEqual( value, ( UInt32 )mpo );
297+
Assert.AreEqual( value, mpo.AsUInt32() );
298+
}
299+
}
300+
}
199301

200302
[Test]
201303
public void TestInt64()
@@ -223,6 +325,23 @@ private static void TestInt64( Int64 value )
223325
Assert.AreEqual( value, ( Int64 )mpo );
224326
Assert.AreEqual( value, mpo.AsInt64() );
225327
}
328+
329+
[Test]
330+
public void TestInt64_Splitted()
331+
{
332+
var value = Int64.MaxValue;
333+
using( var output = new MemoryStream() )
334+
{
335+
Packer.Create( output ).Pack( value );
336+
output.Position = 0;
337+
using( var splitted = new SplittingStream( output ) )
338+
{
339+
var mpo = Unpacking.UnpackObject( splitted );
340+
Assert.AreEqual( value, ( Int64 )mpo );
341+
Assert.AreEqual( value, mpo.AsInt64() );
342+
}
343+
}
344+
}
226345

227346
[Test]
228347
public void TestUInt64()
@@ -249,6 +368,23 @@ private static void TestUInt64( UInt64 value )
249368
Assert.AreEqual( value, ( UInt64 )mpo );
250369
Assert.AreEqual( value, mpo.AsUInt64() );
251370
}
371+
372+
[Test]
373+
public void TestUInt64_Splitted()
374+
{
375+
var value = UInt64.MaxValue;
376+
using( var output = new MemoryStream() )
377+
{
378+
Packer.Create( output ).Pack( value );
379+
output.Position = 0;
380+
using( var splitted = new SplittingStream( output ) )
381+
{
382+
var mpo = Unpacking.UnpackObject( splitted );
383+
Assert.AreEqual( value, ( UInt64 )mpo );
384+
Assert.AreEqual( value, mpo.AsUInt64() );
385+
}
386+
}
387+
}
252388

253389
[Test]
254390
public void TestSingle()
@@ -280,6 +416,23 @@ private static void TestSingle( Single value )
280416
Assert.AreEqual( value, ( Single )mpo, 10e-10 );
281417
Assert.AreEqual( value, mpo.AsSingle(), 10e-10 );
282418
}
419+
420+
[Test]
421+
public void TestSingle_Splitted()
422+
{
423+
var value = Single.MaxValue;
424+
using( var output = new MemoryStream() )
425+
{
426+
Packer.Create( output ).Pack( value );
427+
output.Position = 0;
428+
using( var splitted = new SplittingStream( output ) )
429+
{
430+
var mpo = Unpacking.UnpackObject( splitted );
431+
Assert.AreEqual( value, ( Single )mpo );
432+
Assert.AreEqual( value, mpo.AsSingle() );
433+
}
434+
}
435+
}
283436

284437
[Test]
285438
public void TestDouble()
@@ -311,5 +464,22 @@ private static void TestDouble( Double value )
311464
Assert.AreEqual( value, ( Double )mpo, 10e-10 );
312465
Assert.AreEqual( value, mpo.AsDouble(), 10e-10 );
313466
}
467+
468+
[Test]
469+
public void TestDouble_Splitted()
470+
{
471+
var value = Double.MaxValue;
472+
using( var output = new MemoryStream() )
473+
{
474+
Packer.Create( output ).Pack( value );
475+
output.Position = 0;
476+
using( var splitted = new SplittingStream( output ) )
477+
{
478+
var mpo = Unpacking.UnpackObject( splitted );
479+
Assert.AreEqual( value, ( Double )mpo );
480+
Assert.AreEqual( value, mpo.AsDouble() );
481+
}
482+
}
483+
}
314484
}
315485
}

test/MsgPack.UnitTest/PackUnpackTest.Scalar.tt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,23 @@ foreach( var __type in __integerTypes )
125125
Assert.AreEqual( value, ( <#= __type.Name #> )mpo );
126126
Assert.AreEqual( value, mpo.As<#= __type.Name #>() );
127127
}
128+
129+
[Test]
130+
public void Test<#= __type.Name #>_Splitted()
131+
{
132+
var value = <#= __type.Name #>.MaxValue;
133+
using( var output = new MemoryStream() )
134+
{
135+
Packer.Create( output ).Pack( value );
136+
output.Position = 0;
137+
using( var splitted = new SplittingStream( output ) )
138+
{
139+
var mpo = Unpacking.UnpackObject( splitted );
140+
Assert.AreEqual( value, ( <#= __type.Name #> )mpo );
141+
Assert.AreEqual( value, mpo.As<#= __type.Name #>() );
142+
}
143+
}
144+
}
128145
<#
129146
}
130147

@@ -162,6 +179,23 @@ foreach( var __type in __floatingTypes )
162179
Assert.AreEqual( value, ( <#= __type.Name #> )mpo, 10e-10 );
163180
Assert.AreEqual( value, mpo.As<#= __type.Name #>(), 10e-10 );
164181
}
182+
183+
[Test]
184+
public void Test<#= __type.Name #>_Splitted()
185+
{
186+
var value = <#= __type.Name #>.MaxValue;
187+
using( var output = new MemoryStream() )
188+
{
189+
Packer.Create( output ).Pack( value );
190+
output.Position = 0;
191+
using( var splitted = new SplittingStream( output ) )
192+
{
193+
var mpo = Unpacking.UnpackObject( splitted );
194+
Assert.AreEqual( value, ( <#= __type.Name #> )mpo );
195+
Assert.AreEqual( value, mpo.As<#= __type.Name #>() );
196+
}
197+
}
198+
}
165199
<#
166200
}
167201
#>

0 commit comments

Comments
 (0)