BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
basictest_read.c File Reference
#include "basictest.h"

Data Structures

struct  field
struct  text

Macros

#define MAXFIELDS   10

Functions

static int is (const struct field *f, const char *s)
static int hexval (uint8_t c)
static int decimal (const uint8_t *s, size_t n, uint32_t *v)
static int longval (const struct field *f, uint32_t *v)
static int strval (uint8_t *s, size_t n, struct basictest_str *v)
static unsigned string_value (struct field *f, struct basictest_str *v, uint32_t *length, uint32_t *crc, int *cut)
static int string_values (struct field *f, struct basictest_entry *e)
static int fail (struct basictest_error *err, int code, unsigned field)
int basictest_read (uint8_t *line, size_t length, uint32_t line_number, struct basictest_entry *e, struct basictest_error *err)
 Reads one line of the result file (without its LF) into e.
static void tput (struct text *t, char c)
static void tputs (struct text *t, const char *s)
static void tdecimal (struct text *t, uint32_t v)
size_t basictest_error_text (const struct basictest_error *err, char *buf, size_t size)
 Writes the text of a reader error ("line 3: check: malformed value in field 5"), 0-terminated, cut to fit size bytes (size > 0). The entry name is written as a string value.

Variables

struct { 
   const char *   name 
   int   kind 
   unsigned   fields 
} kinds []

Macro Definition Documentation

◆ MAXFIELDS

#define MAXFIELDS   10

Function Documentation

◆ basictest_error_text()

size_t basictest_error_text ( const struct basictest_error * err,
char * buf,
size_t size )

Writes the text of a reader error ("line 3: check: malformed value in field 5"), 0-terminated, cut to fit size bytes (size > 0). The entry name is written as a string value.

Returns
the length of the text without the 0.

◆ basictest_read()

int basictest_read ( uint8_t * line,
size_t length,
uint32_t line_number,
struct basictest_entry * e,
struct basictest_error * err )

Reads one line of the result file (without its LF) into e.

The string values are decoded in place: e's strings point into line, which the call changes. line_number is the number of the line in the file, for the error.

Returns
BASICTEST_OK, or the reason; err (if not NULL) then names line, reason and field.

◆ decimal()

int decimal ( const uint8_t * s,
size_t n,
uint32_t * v )
static

◆ fail()

int fail ( struct basictest_error * err,
int code,
unsigned field )
static

◆ hexval()

int hexval ( uint8_t c)
static

◆ is()

int is ( const struct field * f,
const char * s )
static

◆ longval()

int longval ( const struct field * f,
uint32_t * v )
static

◆ string_value()

unsigned string_value ( struct field * f,
struct basictest_str * v,
uint32_t * length,
uint32_t * crc,
int * cut )
static

◆ string_values()

int string_values ( struct field * f,
struct basictest_entry * e )
static

◆ strval()

int strval ( uint8_t * s,
size_t n,
struct basictest_str * v )
static

◆ tdecimal()

void tdecimal ( struct text * t,
uint32_t v )
static

◆ tput()

void tput ( struct text * t,
char c )
static

◆ tputs()

void tputs ( struct text * t,
const char * s )
static

Variable Documentation

◆ fields

unsigned fields

◆ kind

int kind

◆ [struct]

const struct { ... } kinds[]
Initial value:
= {
{ "begin", BASICTEST_BEGIN, 2 },
{ "block", BASICTEST_BLOCK, 0 },
{ "check", BASICTEST_CHECK, 5 },
{ "checkq", BASICTEST_CHECKQ, 5 },
{ "checkflt", BASICTEST_CHECKFLT, 6 },
{ "checkstr", BASICTEST_CHECKSTR, 10 },
{ "require", BASICTEST_REQUIRE, 3 },
{ "expect-error", BASICTEST_EXPECT_ERROR, 2 },
{ "blockend", BASICTEST_BLOCKEND, 1 },
{ "broken", BASICTEST_BROKEN, 2 },
{ "incomplete", BASICTEST_INCOMPLETE, 1 },
{ "end", BASICTEST_END, 1 },
{ "run", BASICTEST_RUN, 2 },
{ "runend", BASICTEST_RUNEND, 3 },
}
@ BASICTEST_RUNEND
Definition basictest.h:83
@ BASICTEST_EXPECT_ERROR
Definition basictest.h:75
@ BASICTEST_END
Definition basictest.h:79
@ BASICTEST_BROKEN
Definition basictest.h:77
@ BASICTEST_BLOCKEND
Definition basictest.h:76
@ BASICTEST_CHECK
Definition basictest.h:72
@ BASICTEST_CHECKFLT
Definition basictest.h:81
@ BASICTEST_BLOCK
Definition basictest.h:71
@ BASICTEST_RUN
Definition basictest.h:82
@ BASICTEST_INCOMPLETE
Definition basictest.h:78
@ BASICTEST_CHECKQ
Definition basictest.h:80
@ BASICTEST_REQUIRE
Definition basictest.h:74
@ BASICTEST_BEGIN
Definition basictest.h:70
@ BASICTEST_CHECKSTR
Definition basictest.h:73

◆ name

const char* name