Livt packages
Livt.Collections
Version 1.4.5
Fixed-capacity FIFOs, queues, stacks, circular buffers, lists, and bit sets for Livt hardware.
Published files (69)
tests/list/ListIteratorTest.lvt
namespace Livt.Collections.Tests.List
using Livt.Collections.List
/**
* Exercises ListIterator with a shared fixture instance. Each scenario establishes the
* inputs and state it needs.
*/
@Test
component ListIteratorTest
{
// Shared fixture instances, signals, and observation state.
values: IList<byte>
first: ListIterator<byte>
second: ListIterator<byte>
/**
* Creates the shared fixture instances (List8, ListIterator). Tests initialize the state
* required by their scenario.
*/
new()
{
values = new List8()
first = new ListIterator<byte>(values)
second = new ListIterator<byte>(values)
}
/**
* Checks the independent cursors case.
*/
@Test
fn IndependentCursors()
{
values.Clear()
values.Add(0x01)
values.Add(0x02)
values.Add(0x03)
first.Reset()
second.Reset()
var sum = 0
while (first.HasNext()) {
var value = first.Next()
sum += value as int
}
assert sum == 6
var next = second.Next()
assert next == 0x01
var size = values.GetSize()
assert size == 3
first.Reset()
var repeated = first.Next()
assert repeated == 0x01
}
}