Skip to content

Instantly share code, notes, and snippets.

@sakapon
Last active September 2, 2020 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakapon/26dcf40b8daa77a891a6c8db2275100d to your computer and use it in GitHub Desktop.
Save sakapon/26dcf40b8daa77a891a6c8db2275100d to your computer and use it in GitHub Desktop.
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