-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed spill memory stream bugs. Added tests to verify spilling.
- Loading branch information
Laszlo Dobos
committed
Oct 31, 2014
1 parent
fd002be
commit bb1ba17
Showing
3 changed files
with
190 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.IO; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Jhu.SharpFitsIO | ||
{ | ||
[TestClass] | ||
public class SpillMemoryStreamTest | ||
{ | ||
[TestMethod] | ||
public void MemoryOnlyTest() | ||
{ | ||
var buffer = new byte[0x10000]; // 64k | ||
|
||
using (var sms = new SpillMemoryStream()) | ||
{ | ||
sms.Write(buffer, 0, buffer.Length); | ||
|
||
var ms = new MemoryStream(); | ||
sms.WriteTo(ms); | ||
|
||
Assert.AreEqual(0x10000, ms.Position); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void SpillToTempTest() | ||
{ | ||
var buffer = new byte[0x10000]; // 64k | ||
|
||
using (var sms = new SpillMemoryStream()) | ||
{ | ||
// Write 2M | ||
for (int i = 0; i < 32; i++) | ||
{ | ||
sms.Write(buffer, 0, buffer.Length); | ||
} | ||
|
||
var ms = new MemoryStream(); | ||
sms.WriteTo(ms); | ||
|
||
Assert.AreEqual(0x200000, ms.Position); | ||
} | ||
} | ||
} | ||
} |