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/bitset/BitSet8Test.lvt
namespace Livt.Collections.Tests.BitSet
using Livt.Collections.BitSet
/**
* Exercises BitSet8 with a shared fixture instance. Each scenario establishes the inputs
* and state it needs.
*/
@Test
component BitSet8Test
{
// Shared fixture instances, signals, and observation state.
bits: BitSet8
/**
* Creates the shared fixture instances (BitSet8). Tests initialize the state required by
* their scenario.
*/
new()
{
bits = new BitSet8()
}
/**
* Checks that Set clear and value.
*/
@Test
fn TestSetClearAndValue()
{
bits.Reset()
bits.Set(0)
bits.Set(2)
bits.Set(7)
assert bits.IsSet(0) == true
assert bits.IsSet(2) == true
assert bits.IsSet(7) == true
assert bits.GetValue() == 133
bits.Clear(2)
assert bits.GetValue() == 129
}
/**
* Checks the toggle case.
*/
@Test
fn TestToggle()
{
bits.Reset()
bits.Toggle(3)
assert bits.IsSet(3) == true
bits.Toggle(3)
assert bits.IsSet(3) == false
}
/**
* Checks that Any none and reset.
*/
@Test
fn TestAnyNoneAndReset()
{
bits.Reset()
assert bits.None() == true
assert bits.Any() == false
bits.Set(5)
assert bits.Any() == true
assert bits.None() == false
bits.Reset()
assert bits.None() == true
}
/**
* Checks the bounds and capacity case.
*/
@Test
fn TestBoundsAndCapacity()
{
bits.Reset()
bits.Set(-1)
bits.Set(8)
bits.Toggle(9)
bits.Clear(-1)
bits.Clear(8)
assert bits.GetValue() == 0
assert bits.IsSet(-1) == false
assert bits.IsSet(8) == false
assert bits.GetCapacity() == 8
}
}