This commit is contained in:
h z
2025-01-18 08:30:10 +00:00
commit a59602d1c7
11 changed files with 802 additions and 0 deletions

46
tests/EvoluteTests.cs Normal file
View File

@@ -0,0 +1,46 @@
using NUnit.Framework;
namespace InverseOfLife.Test;
[TestFixture]
public class EvoluteTests
{
[Test]
public void Mutate_ShouldModifyBitsBasedOnRate()
{
int resolution = 3;
byte[] riboseSequence = [0b10101010, 0b11110000, 0b00001111, 0b00110011];
var gene = new Gene(resolution, riboseSequence);
float mutationRate = 1.0f;
var mutatedGene = gene.Mutate(0, mutationRate);
Assert.That(mutatedGene.RiboseSequence, Is.Not.EqualTo(riboseSequence));
}
[Test]
public void Mutate_WithZeroRate_ShouldNotChangeRiboseSequence()
{
int resolution = 3;
byte[] riboseSequence = [0b10101010, 0b11110000, 0b00001111, 0b00110011];
var gene = new Gene(resolution, riboseSequence);
float mutationRate = 0.0f;
var mutatedGene = gene.Mutate(0, mutationRate);
Assert.That(mutatedGene.RiboseSequence, Is.EqualTo(riboseSequence));
}
[Test]
public void Mutate_WithSpecificRiboseIndex_ShouldOnlyAffectSpecifiedIndex()
{
int resolution = 3;
byte[] riboseSequence = [0b10101010, 0b11110000, 0b00001111, 0b00001111];
var gene = new Gene(resolution, riboseSequence);
float mutationRate = 0.5f;
int riboseIndex = 1;
var mutatedGene = gene.Mutate(riboseIndex, mutationRate);
Assert.That(mutatedGene.RiboseSequence[0], Is.EqualTo(riboseSequence[0]));
}
}