-
Notifications
You must be signed in to change notification settings - Fork 0
/
BitMathTest.cs
50 lines (44 loc) · 1.33 KB
/
BitMathTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// This file is part of bugreport.
// Copyright (c) 2006-2009 The bugreport Developers.
// See AUTHORS.txt for details.
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
using System;
using NUnit.Framework;
namespace bugreport
{
[TestFixture]
public class BitMathTest
{
[Test]
public void AllZeroes()
{
var result = BitMath.BytesToDword(new Byte[] {0, 0, 0, 0}, 0);
Assert.AreEqual(0, result);
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void EmptyBytes()
{
BitMath.BytesToDword(new Byte[] {}, 0);
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void NotEnoughBytesToDwordAtNonZeroIndex()
{
BitMath.BytesToDword(new Byte[] {0, 1, 2, 3}, 1);
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void NotEnoughBytesToDwordAtZeroIndex()
{
BitMath.BytesToDword(new Byte[] {0}, 0);
}
[Test]
public void OneTwoThreeFour()
{
var result = BitMath.BytesToDword(new Byte[] {1, 2, 3, 4}, 0);
Assert.AreEqual(0x04030201, result);
}
}
}