package
1.2.12
Repository: https://github.com/cpmech/gosl.git
Documentation: pkg.go.dev

# README

Gosl. chk. Check code and unit test tools

Go Reference

Package chk provides tools to check numerical results and to perform unit tests.

API

Please see the documentation here

# Functions

AnaNum compares analytical versus numerical values.
AnaNumC compares analytical versus numerical values (complex version).
Array compares two array.
ArrayC compares two slices of complex nummber.
Bool compares two bools.
Bools compare two slices of bool.
CallerInfo returns the file and line positions where an error occurred idx -- use idx=2 to get the caller of Panic.
CentralDeriv Computes the derivative using the 5-point rule (x-h, x-h/2, x, x+h/2, x+h).
Complex128 compares two complex128 numbers.
Deep2 compares two nested (depth=2) slice.
Deep2c compares two nested (depth=2) slices.
Deep3 compares two deep3 slices.
Deep4 compares two deep4 slices.
DerivScaSca checks the derivative of scalar w.r.t scalar by comparing with numerical solution obtained with central differences (5-point rule) Checks: df │ g = —— │ with f:scalar, x:scalar dx │xAt g:scalar Input: tst -- testing.T structure msg -- message about this test tol -- tolerance to compare gAna with gNum gAna -- [scalar] analytical (or other kind) derivative dfdx xAt -- [scalar] position to compute dfdx h -- initial stepsize; e.g.
DerivScaVec checks the derivative of scalar w.r.t vector by comparing with numerical solution obtained with central differences (5-point rule) Check: df │ f:scalar {x}:vector {g} = ———— │ with {g}:vector d{x} │{xAt} len(g) == len(x) == len(xAt) Input: tst -- testing.T structure msg -- message about this test tol -- tolerance to compare gAna with gNum gAna -- [vector] analytical (or other kind) derivative dfdx.
DerivVecSca checks the derivative of vector w.r.t scalar by comparing with numerical solution obtained with central differences (5-point rule) Check: d{f} │ {f}:vector x:scalar {g} = ———— │ with {g}:vector dx │xAt len(g) == len(f) Input: tst -- testing.T structure msg -- message about this test tol -- tolerance to compare gAna with gNum gAna -- [vector] analytical (or other kind) derivative dfdx.
DerivVecVec checks the derivative of vector w.r.t vector by comparing with numerical solution obtained with central differences (5-point rule) Checks: d{f} │ {f}:vector {x}:vector [g] = ———— │ with [g]:matrix d{x} │{xAt} rows(g)==len(f) cols(g)==len(x)==len(xAt) Input: tst -- testing.T structure msg -- message about this test tol -- tolerance to compare gAna with gNum gAna -- [matrix] analytical (or other kind) derivative dfdx.
Err returns a new error.
Float64 compares two float64 numbers.
Float64assert asserts that a is equal to b (floats).
Int compares two ints.
Int32 compares two int32.
Int32s compares two slices of 32 integer.
Int64 compares two int64.
Int64s compares two slices of 64 integer.
IntAssert asserts that a is equal to b (ints).
IntAssertLessThan asserts that a < b (ints).
IntAssertLessThanOrEqualTo asserts that a ≤ b (ints).
IntDeep2 compares nested slices of ints.
Ints compares two slices of integer.
Panic calls CallerInfo and panics.
PanicSimple panics without calling CallerInfo.
PrintAnaNum formats the output of analytical versus numerical comparisons.
PrintAnaNumC formats the output of analytical versus numerical comparisons (complex version).
PrintOk prints "OK" in green (if ColorsOn==true).
PrintTitle returns the Test Title.
Recover catches panics and call os.Exit(1) on 'panic'.
RecoverTst catches panics in tests.
RecoverTstPanicIsOK catches panics in tests.
StrAssert asserts that a is equal to b (strings).
StrDeep2 compares nested slices of strings.
String compares two strings.
Strings compare two slices of string.
Symmetry checks symmetry of SEGMENTS in an even or odd slice of float64 NOTE: values in X must be sorted ascending .
TestDiffC tests difference between complex128.
TstDiff tests difference between float64.
TstFail calls tst.Errorf() with msg and parameters.

# Variables

AssertOn activates or deactivates asserts.
ColorsOn turn on use of colours on console.
Verbose turn on verbose mode.