Skip to content

Instantly share code, notes, and snippets.

@sakapon

sakapon/BitArrayTest.cs

Last active Sep 2, 2020
Embed
What would you like to do?
OperatorsSample/BitArrayTest.Indexer
[TestMethod]
public void Indexer()
{
BitArray b = 10;
Assert.AreEqual(false, b[0]);
Assert.AreEqual(true, b[1]);
Assert.AreEqual(false, b[2]);
Assert.AreEqual(true, b[3]);
Assert.AreEqual(false, b[4]);
Assert.AreEqual(false, b[5]);
Assert.AreEqual(false, b[^27]); // Index
Assert.AreEqual(10, (int)b);
b[5] = true;
Assert.AreEqual(true, b[5]);
Assert.AreEqual(true, b[^27]); // Index
Assert.AreEqual(42, (int)b);
}
[TestMethod]
public void Initializer()
{
var b = new BitArray
{
[3] = true,
[6] = true,
};
Assert.AreEqual(72, b.Value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment