Livt packages
Livt.Collections
Version 1.4.2
Fixed-capacity FIFOs, queues, stacks, circular buffers, lists, and bit sets for Livt hardware.
Published files (62)
tests/stack/Stack8Test.lvt
namespace Livt.Collections.Tests.Stack
using Livt.Collections.Stack
/**
* Exercises Stack8 with a shared fixture instance. Each scenario establishes the inputs
* and state it needs.
*/
@Test
component Stack8Test
{
// Shared fixture instances, signals, and observation state.
stack: Stack8
/**
* Creates the shared fixture instances (Stack8). Tests initialize the state required by
* their scenario.
*/
new()
{
this.stack = new Stack8()
}
/**
* Checks the capacity and rejected push case.
*/
@Test
fn TestCapacityAndRejectedPush()
{
this.stack.Clear()
for (var i = 0; i < 8; i++) {
this.stack.Push(0b0000_0001)
}
this.stack.Push(0b0000_0010)
assert this.stack.IsFull() == true
assert this.stack.GetSize() == 8
for (var i = 0; i < 8; i++) {
assert this.stack.Pop() == 0b0000_0001
}
}
/**
* Checks the empty reads return zero case.
*/
@Test
fn TestEmptyReadsReturnZero()
{
this.stack.Clear()
assert this.stack.Peek() == 0b0000_0000
assert this.stack.Pop() == 0b0000_0000
}
}