libtinylor
Single-file header library for controlling Light-O-Rama hardware
Loading...
Searching...
No Matches
tinylor_test.c File Reference
#include <assert.h>
#include "tinylor.h"
Include dependency graph for tinylor_test.c:

Functions

static void test_channel_format_header (const unsigned short cbits, const lor_channel_format expected)
 Tests the channel format header byte selection.
 
static void test_channel_alignment (const lor_channel first, const unsigned short cbits, const lor_channel_set expected)
 Tests the channel alignment calculation.
 
static void assert_frame (const unsigned char *b, const size_t written, const unsigned char *expected, const size_t expected_size)
 Asserts an encoded frame matches the expected bytes exactly, and that the 0x00 frame delimiter does not appear between the two delimiters.
 
static void test_single_channel_byte (const lor_channel c, const unsigned char expected)
 Tests the single channel byte encoding (0x80 | channel index).
 
static void test_channel_set_frame (const unsigned short cbits, const unsigned char *expected, const size_t expected_size)
 Tests the encoded frame of a channel set request, from the leading 0x00 delimiter through the trailing one.
 
static void test_intensity_frame (const unsigned short cbits, const lor_intensity intensity, const unsigned char *expected, const size_t expected_size)
 Tests that effect parameters are encoded before the channel bytes.
 
static void test_unit_set_add (const lor_unit unit)
 Tests the unit set bit storage for a single unit.
 
static void test_unit_list_frame (const lor_unit *units, const size_t us, const unsigned char *expected, const size_t expected_size)
 Tests the encoded frame of a request addressed to a set of units, from the leading 0x00 delimiter through the trailing one.
 
int main (void)
 

Function Documentation

◆ assert_frame()

static void assert_frame ( const unsigned char *  b,
const size_t  written,
const unsigned char *  expected,
const size_t  expected_size 
)
static

Asserts an encoded frame matches the expected bytes exactly, and that the 0x00 frame delimiter does not appear between the two delimiters.

Parameters
bThe buffer holding the encoded frame.
writtenThe number of bytes written to b.
expectedThe expected frame bytes, including both delimiters.
expected_sizeThe number of bytes in expected.
Here is the caller graph for this function:

◆ main()

int main ( void  )
Here is the call graph for this function:

◆ test_channel_alignment()

static void test_channel_alignment ( const lor_channel  first,
const unsigned short  cbits,
const lor_channel_set  expected 
)
static

Tests the channel alignment calculation.

Parameters
firstThe first channel to encode.
cbits16-bit bitset of channels relative to first to encode.
expectedThe expected channel alignment result.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_channel_format_header()

static void test_channel_format_header ( const unsigned short  cbits,
const lor_channel_format  expected 
)
static

Tests the channel format header byte selection.

Parameters
cbits16-bit bitset of channels to encode.
expectedThe expected channel format header byte.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_channel_set_frame()

static void test_channel_set_frame ( const unsigned short  cbits,
const unsigned char *  expected,
const size_t  expected_size 
)
static

Tests the encoded frame of a channel set request, from the leading 0x00 delimiter through the trailing one.

Parameters
cbits16-bit bitset of channels to encode.
expectedThe expected frame bytes.
expected_sizeThe number of bytes in expected.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_intensity_frame()

static void test_intensity_frame ( const unsigned short  cbits,
const lor_intensity  intensity,
const unsigned char *  expected,
const size_t  expected_size 
)
static

Tests that effect parameters are encoded before the channel bytes.

Parameters
cbits16-bit bitset of channels to encode.
intensityThe intensity parameter to encode.
expectedThe expected frame bytes.
expected_sizeThe number of bytes in expected.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_single_channel_byte()

static void test_single_channel_byte ( const lor_channel  c,
const unsigned char  expected 
)
static

Tests the single channel byte encoding (0x80 | channel index).

Parameters
cThe 0-based channel index to encode.
expectedThe expected channel byte.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_unit_list_frame()

static void test_unit_list_frame ( const lor_unit *  units,
const size_t  us,
const unsigned char *  expected,
const size_t  expected_size 
)
static

Tests the encoded frame of a request addressed to a set of units, from the leading 0x00 delimiter through the trailing one.

Parameters
unitsThe units to include in the set.
usThe number of units in units.
expectedThe expected frame bytes.
expected_sizeThe number of bytes in expected.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_unit_set_add()

static void test_unit_set_add ( const lor_unit  unit)
static

Tests the unit set bit storage for a single unit.

Parameters
unitThe unit to add to an otherwise empty set.
Here is the call graph for this function:
Here is the caller graph for this function: