Livt packages
Livt.Math
Version 1.7.2
Reusable integer and fixed-point arithmetic, complex numbers, trigonometry, and statistics for FPGA applications written in Livt.
Published files (90)
tests/sqrt/SqrtInt32Test.lvt
namespace Livt.Math.Tests.Sqrt
using Livt.Math.Sqrt
/**
* Exercises SqrtInt32 with a shared fixture instance. Each scenario establishes the inputs
* and state it needs.
*/
@Test
component SqrtInt32Test
{
// Shared fixture instances, signals, and observation state.
sqrt: SqrtInt32
/**
* Creates the shared fixture instances (SqrtInt32). Tests initialize the state required by
* their scenario.
*/
new()
{
this.sqrt = new SqrtInt32()
}
/**
* Checks that Compute s large and boundary values.
*/
@Test
fn ComputesLargeAndBoundaryValues()
{
assert this.sqrt.Compute(-1) == 0
assert this.sqrt.Compute(0) == 0
assert this.sqrt.Compute(1) == 1
assert this.sqrt.Compute(2) == 1
assert this.sqrt.Compute(3) == 1
assert this.sqrt.Compute(4) == 2
assert this.sqrt.Compute(15) == 3
assert this.sqrt.Compute(16) == 4
assert this.sqrt.Compute(17) == 4
assert this.sqrt.Compute(1048576) == 1024
assert this.sqrt.Compute(2147395600) == 46340
assert this.sqrt.Compute(2147483647) == 46340
}
}