public unsafe void AddTailMultiple_WithZeroCount_DoesNotAdd() { m_MultiList.AddHead(0, "0a"); m_MultiList.AddTail(0, null, 0); MultiListDebugUtility.ValidateIntegrity(ref m_MultiList); var data = MultiListDebugUtility.SelectAllData(m_MultiList); Assert.That(data, Is.EqualTo(new[] { new[] { "0a" } })); }
public unsafe void AddTailMultiple_WithSingle_AddsSingle() { m_MultiList.AddHead(0, "0a"); int id; m_MultiList.AddTail(0, &id, 1); m_MultiList.Data.Data[id] = "0b"; MultiListDebugUtility.ValidateIntegrity(ref m_MultiList); var data = MultiListDebugUtility.SelectAllData(m_MultiList); Assert.That(data, Is.EqualTo(new[] { new[] { "0a", "0b" } })); }
public void Add_BuildsNewList() { m_MultiList.Add(0, "0a"); // add head m_MultiList.Add(0, "0b"); // add after head m_MultiList.Add(0, "0c"); // add after head m_MultiList.Add(0, "0d"); // add after head Assert.That(m_MultiList.HeadIds.Take(1), Is.EqualTo(new[] { 0 })); Assert.That(m_MultiList.Next.Take(4), Is.EqualTo(new[] { 3, -1, 1, 2 })); var data = MultiListDebugUtility.SelectAllData(m_MultiList); Assert.That(data, Is.EqualTo(new[] { new[] { "0a", "0d", "0c", "0b" }, })); }
public void AddTail_WithExistingHead_AddsEnd() { m_MultiList.AddHead(0, "0"); m_MultiList.AddTail(0, "0a"); m_MultiList.AddHead(1, "1"); m_MultiList.AddTail(0, "0b"); var serial = m_MultiList.AddTail(0, "0c").serial; Assert.That(serial, Is.EqualTo(3)); Assert.That(MultiListDebugUtility.SelectAllData(m_MultiList), Is.EqualTo(new[] { new[] { "0", "0a", "0b", "0c" }, new[] { "1" } })); }
public void Add_WithInterleavingAddHead_ProperlyLinksLists() { m_MultiList.AddHead(0, "0"); m_MultiList.Add(0, "0a"); m_MultiList.AddHead(1, "1"); m_MultiList.Add(0, "0b"); m_MultiList.Add(2, "2"); var data = MultiListDebugUtility.SelectAllData(m_MultiList).ToList(); Assert.That(data.Count, Is.EqualTo(3)); Assert.That(data[0], Is.EquivalentTo(new[] { "0", "0b", "0a" })); Assert.That(data[1], Is.EquivalentTo(new[] { "1" })); Assert.That(data[2], Is.EquivalentTo(new[] { "2" })); }
public void AddTail_WithDeferredDataSet_Matches() { m_MultiList.AddHead(0, "0"); m_MultiList.AddTail(0, "0a"); var added = m_MultiList.AddTail(0); m_MultiList.AddTail(0, "0c"); Assert.That(MultiListDebugUtility.SelectAllData(m_MultiList), Is.EqualTo( new[] { new[] { "0", "0a", null, "0c" } })); m_MultiList.Data[added.id] = "0b"; Assert.That(MultiListDebugUtility.SelectAllData(m_MultiList), Is.EqualTo( new[] { new[] { "0", "0a", "0b", "0c" } })); }
public unsafe void AddTailMultiple_WithMultiple_AddsMultiple() { m_MultiList.AddHead(0, "0a"); int *ids = stackalloc int[5]; m_MultiList.AddTail(0, ids, 5); m_MultiList.Data.Data[ids[0]] = "0b"; m_MultiList.Data.Data[ids[1]] = "0c"; m_MultiList.Data.Data[ids[2]] = "0d"; m_MultiList.Data.Data[ids[3]] = "0e"; m_MultiList.Data.Data[ids[4]] = "0f"; MultiListDebugUtility.ValidateIntegrity(ref m_MultiList); var data = MultiListDebugUtility.SelectAllData(m_MultiList); Assert.That(data, Is.EqualTo(new[] { new[] { "0a", "0b", "0c", "0d", "0e", "0f" } })); }
public void ReleaseListKeepHead_WithHead_ReleasesEntireListButKeepsHead() { m_MultiList.AddHead(0, "0a"); m_MultiList.AddTail(0, "0b"); m_MultiList.AddHead(1, "1a"); m_MultiList.AddTail(0, "0c"); m_MultiList.AddTail(1, "1b"); var released = m_MultiList.ReleaseListKeepHead(0); Assert.That(released, Is.EqualTo(2)); Assert.That(m_MultiList.HeadIds.Take(2), Is.EqualTo(new[] { 0, 2 })); Assert.That(MultiListDebugUtility.SelectAllData(m_MultiList), Is.EqualTo( new[] { new[] { "0a" }, new[] { "1a", "1b" } })); }
public void TearDown() { MultiListDebugUtility.ValidateIntegrity(ref m_MultiList); }