init
This commit is contained in:
45
tests/GeneIndexerTest.cs
Normal file
45
tests/GeneIndexerTest.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace InverseOfLife.Test;
|
||||
|
||||
[TestFixture]
|
||||
public class GeneIndexerTests
|
||||
{
|
||||
[Test]
|
||||
public void Indexer_GranularityPositive_ReadWriteBytes()
|
||||
{
|
||||
var riboseSequence = new byte[] { 0b10101010, 0b11110000, 0b00001111, 0b11001100 };
|
||||
var gene = new Gene(3, riboseSequence);
|
||||
|
||||
byte[] expected = [0b00001111, 0b11001100];
|
||||
Assert.That(gene[1], Is.EqualTo(expected));
|
||||
|
||||
gene[1] = [0b01010101, 0b10101010];
|
||||
Assert.That(gene[1], Is.EqualTo(new byte[] { 0b01010101, 0b10101010 }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Indexer_GranularityNegative_ReadWriteBits()
|
||||
{
|
||||
var riboseSequence = new byte[] { 0b10101010, 0b11110000 };
|
||||
var gene = new Gene(1, riboseSequence);
|
||||
|
||||
byte[] expected = [0b00000001];
|
||||
Assert.That(gene[7], Is.EqualTo(expected));
|
||||
|
||||
gene[7] = [0b00000000];
|
||||
Assert.That(gene[7], Is.EqualTo(new byte[] { 0b00000000 }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Indexer_GranularityExceed_ThrowsException()
|
||||
{
|
||||
var riboseSequence = new byte[] { 0b10101010, 0b11110000 };
|
||||
var gene = new Gene(3, riboseSequence);
|
||||
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
{
|
||||
gene[0] = [0b10101010, 0b11110000, 0b00001111];
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user