BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
tlcore.h File Reference
#include <stddef.h>
#include <stdint.h>
#include "basictest.h"

Go to the source code of this file.

Data Structures

struct  tl_state
 The state of the library; all of it between two guard words. More...
struct  tl_run
struct  tl_run_text

Macros

#define TL_LINE   512 /* the longest entry */
#define TL_PENDING   1024 /* entries kept while they cannot be written */
#define TL_GUARD_LO   0x544C7374UL /* "TLst" */
#define TL_GUARD_HI   0x7473544CUL /* "tsTL" */
#define TL_RUN_TEXT   1024 /* the bytes of the output printed holds */

Enumerations

enum  { TL_NONE = 0 , TL_INIT = BASICTEST_BLOCK_INIT + 1 , TL_CASE = BASICTEST_BLOCK_CASE + 1 , TL_FINAL = BASICTEST_BLOCK_FINAL + 1 }
 The open block (enum basictest_block + 1; TL_NONE: none). More...

Functions

void tl_os_write (const uint8_t *data, size_t length)
int tl_os_can_write (void)
int tl_os_fltnear (uint32_t expected, uint32_t actual, uint32_t delta)
void tl_begin (struct tl_state *st)
 Clears the state and writes begin.
int tl_block (struct tl_state *st, int block, const uint8_t *name, size_t length)
 Opens a block (block: enum basictest_block; name and length: the case name, ignored for the batch init and end).
void tl_blockend (struct tl_state *st)
 Closes the open block.
void tl_check (struct tl_state *st, uint32_t k, uint32_t expected, uint32_t actual)
 A check of two longs: ok if they are equal.
void tl_checkq (struct tl_state *st, uint32_t k, uint32_t expected, uint32_t actual)
 A check of two quicks (their 32 bits): ok if they are equal.
void tl_checkflt (struct tl_state *st, uint32_t k, uint32_t expected, uint32_t actual, uint32_t delta)
 A check of two FFP floats: ok if |actual-expected| <= delta.
void tl_checkstr (struct tl_state *st, uint32_t k, const uint8_t *expected, size_t expected_length, const uint8_t *actual, size_t actual_length)
 A check of two strings (bytes): ok if they are equal.
int tl_require (struct tl_state *st, uint32_t k, uint32_t condition)
 A precondition.
void tl_expect_error (struct tl_state *st, uint32_t k)
 The announcement of an expected runtime error.
void tl_finit (struct tl_state *st)
 The end of the run: kept entries, incomplete if a block is open, end.
int tl_run_start (struct tl_state *st, uint32_t k, struct tl_run *r, struct tl_run_text *t)
 A program is to start (TLRunProgram): the result r and its text t cleared (rc 0, unknown, nothing printed: printed the empty string), and run K written if it may start.
void tl_run_end (struct tl_state *st, uint32_t k, struct tl_run *r, struct tl_run_text *t, int known, int32_t rc, size_t n, uint32_t size)
 The program ended (after tl_run_start gave 1): its output's first n bytes are in t->chars (n <= TL_RUN_TEXT), size the whole output; the result filled (printed of n bytes and a 0 behind, cut if size > n) and runend K written with rc if known, else -.

Macro Definition Documentation

◆ TL_GUARD_HI

#define TL_GUARD_HI   0x7473544CUL /* "tsTL" */

◆ TL_GUARD_LO

#define TL_GUARD_LO   0x544C7374UL /* "TLst" */

◆ TL_LINE

#define TL_LINE   512 /* the longest entry */

◆ TL_PENDING

#define TL_PENDING   1024 /* entries kept while they cannot be written */

◆ TL_RUN_TEXT

#define TL_RUN_TEXT   1024 /* the bytes of the output printed holds */

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

The open block (enum basictest_block + 1; TL_NONE: none).

Enumerator
TL_NONE 
TL_INIT 
TL_CASE 
TL_FINAL 

Function Documentation

◆ tl_begin()

void tl_begin ( struct tl_state * st)

Clears the state and writes begin.

◆ tl_block()

int tl_block ( struct tl_state * st,
int block,
const uint8_t * name,
size_t length )

Opens a block (block: enum basictest_block; name and length: the case name, ignored for the batch init and end).

Returns
1 if the block runs, 0 if it does not (no tl_begin, or after a batch init whose precondition failed).

◆ tl_blockend()

void tl_blockend ( struct tl_state * st)

Closes the open block.

◆ tl_check()

void tl_check ( struct tl_state * st,
uint32_t k,
uint32_t expected,
uint32_t actual )

A check of two longs: ok if they are equal.

◆ tl_checkflt()

void tl_checkflt ( struct tl_state * st,
uint32_t k,
uint32_t expected,
uint32_t actual,
uint32_t delta )

A check of two FFP floats: ok if |actual-expected| <= delta.

◆ tl_checkq()

void tl_checkq ( struct tl_state * st,
uint32_t k,
uint32_t expected,
uint32_t actual )

A check of two quicks (their 32 bits): ok if they are equal.

◆ tl_checkstr()

void tl_checkstr ( struct tl_state * st,
uint32_t k,
const uint8_t * expected,
size_t expected_length,
const uint8_t * actual,
size_t actual_length )

A check of two strings (bytes): ok if they are equal.

◆ tl_expect_error()

void tl_expect_error ( struct tl_state * st,
uint32_t k )

The announcement of an expected runtime error.

◆ tl_finit()

void tl_finit ( struct tl_state * st)

The end of the run: kept entries, incomplete if a block is open, end.

◆ tl_os_can_write()

int tl_os_can_write ( void )

◆ tl_os_fltnear()

int tl_os_fltnear ( uint32_t expected,
uint32_t actual,
uint32_t delta )

◆ tl_os_write()

void tl_os_write ( const uint8_t * data,
size_t length )

◆ tl_require()

int tl_require ( struct tl_state * st,
uint32_t k,
uint32_t condition )

A precondition.

Returns
1 if it failed inside a block: the caller leaves the block (the block's call returns a second time, with 0); 0 otherwise.

◆ tl_run_end()

void tl_run_end ( struct tl_state * st,
uint32_t k,
struct tl_run * r,
struct tl_run_text * t,
int known,
int32_t rc,
size_t n,
uint32_t size )

The program ended (after tl_run_start gave 1): its output's first n bytes are in t->chars (n <= TL_RUN_TEXT), size the whole output; the result filled (printed of n bytes and a 0 behind, cut if size > n) and runend K written with rc if known, else -.

◆ tl_run_start()

int tl_run_start ( struct tl_state * st,
uint32_t k,
struct tl_run * r,
struct tl_run_text * t )

A program is to start (TLRunProgram): the result r and its text t cleared (rc 0, unknown, nothing printed: printed the empty string), and run K written if it may start.

Returns
1 if it may start; 0 if not: no tl_begin, a damaged state, or refused with broken (outside a block, or while entries cannot be written: Blitz mode, Forbid, Disable).