本文整理汇总了C#中System.ByteBuffer.PutShort方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.PutShort方法的具体用法?C# ByteBuffer.PutShort怎么用?C# ByteBuffer.PutShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.PutShort方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ByteBuffer_PutShortPopulatesBufferCorrectly
public void ByteBuffer_PutShortPopulatesBufferCorrectly()
{
var buffer = new byte[2];
var uut = new ByteBuffer(buffer);
uut.PutShort(0, (short)1);
// Ensure Endianness was written correctly
Assert.AreEqual((byte)1, buffer[0]);
Assert.AreEqual((byte)0, buffer[1]);
}
示例2: ByteBuffer_PutShortChecksLengthAndOffset
public void ByteBuffer_PutShortChecksLengthAndOffset()
{
var buffer = new byte[2];
var uut = new ByteBuffer(buffer);
Assert.Throws<ArgumentOutOfRangeException>(() => uut.PutShort(1, 99));
}
示例3: ByteBuffer_PutShortCannotPutAtOffsetPastLength
public void ByteBuffer_PutShortCannotPutAtOffsetPastLength()
{
var buffer = new byte[2];
var uut = new ByteBuffer(buffer);
Assert.Throws<ArgumentOutOfRangeException>(() => uut.PutShort(2, 99));
}
示例4: testHet
private static void testHet(int level, ByteBuffer b)
{
int p = b.Position;
b.Limit = (b.Capacity);
Show(level, b);
output.Write(" put:");
b.PutChar((char)1);
b.PutChar((char)char.MaxValue);
output.Write(" char");
b.PutShort((short)1);
b.PutShort((short)short.MaxValue);
output.Write(" short");
b.PutInt(1);
b.PutInt(int.MaxValue);
output.Write(" int");
b.PutLong((long)1);
b.PutLong((long)long.MaxValue);
output.Write(" long");
b.PutFloat((float)1);
b.PutFloat((float)float.MinValue);
b.PutFloat((float)float.MaxValue);
output.Write(" float");
b.PutDouble((double)1);
b.PutDouble((double)double.MinValue);
b.PutDouble((double)double.MaxValue);
output.Write(" double");
output.WriteLine();
b.Limit = (b.Position);
b.Position = (p);
Show(level, b);
output.Write(" get:");
ck(b, b.GetChar(), 1);
ck(b, b.GetChar(), char.MaxValue);
output.Write(" char");
ck(b, b.GetShort(), 1);
ck(b, b.GetShort(), short.MaxValue);
output.Write(" short");
ck(b, b.GetInt(), 1);
ck(b, b.GetInt(), int.MaxValue);
output.Write(" int");
ck(b, b.GetLong(), 1);
ck(b, b.GetLong(), long.MaxValue);
output.Write(" long");
ck(b, (long)b.GetFloat(), 1);
ck(b, (long)b.GetFloat(), unchecked((long)float.MinValue));
ck(b, (long)b.GetFloat(), unchecked((long)float.MaxValue));
output.Write(" float");
ck(b, (long)b.GetDouble(), 1);
ck(b, (long)b.GetDouble(), unchecked((long)double.MinValue));
ck(b, (long)b.GetDouble(), unchecked((long)double.MaxValue));
output.Write(" double");
output.WriteLine();
}