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/stack/Stack16Test.lvt
namespace Livt.Collections.Tests.Stack
using Livt.Collections.Stack
/**
* Exercises Stack16 with a shared fixture instance. Each scenario establishes the inputs
* and state it needs.
*/
@Test
component Stack16Test
{
// Shared fixture instances, signals, and observation state.
stack: Stack16
/**
* Creates the shared fixture instances (Stack16). Tests initialize the state required by
* their scenario.
*/
new()
{
stack = new Stack16()
}
/**
* Checks the capacity and lifo order case.
*/
@Test
fn TestCapacityAndLifoOrder()
{
stack.Clear()
stack.Push(0b0000_0010)
for (var i = 1; i < 16; i++) {
stack.Push(0b0000_0001)
}
assert stack.IsFull() == true
assert stack.GetSize() == 16
for (var i = 1; i < 16; i++) {
assert stack.Pop() == 0b0000_0001
}
assert stack.Pop() == 0b0000_0010
}
/**
* Checks that Clear allows reuse.
*/
@Test
fn TestClearAllowsReuse()
{
stack.Clear()
stack.Push(0b0000_0001)
stack.Clear()
stack.Push(0b0000_0010)
assert stack.GetSize() == 1
assert stack.Pop() == 0b0000_0010
}
}