3-phase PV router
Loading...
Searching...
No Matches
test_main.cpp File Reference

Native tests for teleinfo.h: the IoT frame, streamed a line per step. More...

#include <unity.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "teleinfo.h"
Include dependency graph for test_main.cpp:

Go to the source code of this file.

Classes

struct  Line
 A line of a frame: its tag (with the index) and its value. More...
 
class  Reference
 The buffered TeleInfo class of the firmware, as it was (utoa() aside): the reference of the frame. Its frame differs in two places only (referenceFrame()): N and each V are sent unsigned. More...
 
struct  Streamed
 A frame as the serial output writes it: every step, one after the other. More...
 
struct  TestSource< PHASES >
 A data source of writeFrameStep(): 2 loads, 1 relay, 2 temperature sensors (the 2nd invalid). More...
 
struct  Values
 The values of a datalog, shared by every test source. More...
 

Typedefs

using Default = TestSource< 3, 0, 3, 0, false >
 
using DualTariff = TestSource< 3, 0, 3, 0, true >
 
using Everything = TestSource< 3, 2, 4, 4, true >
 
using Minimal = TestSource< 3, 0, 1, 0, false >
 
using Relays = TestSource< 3, 2, 3, 0, false >
 
using SinglePhase = TestSource< 1, 0, 1, 0, false >
 
using Temperatures = TestSource< 3, 0, 3, 2, false >
 

Functions

template<typename Source>
static void assertSameAsReference (const char *message)
 
static uint8_t countTag (const Line(&lines)[32], uint8_t count, const char *tag)
 How many lines have exactly this tag.
 
static void extremeValues ()
 The extremes of every value.
 
int main (int, char **)
 
static uint8_t parseFrame (const Streamed &frame, Line(&lines)[32])
 Splits a frame into its lines, as a receiver does, checking STX, ETX and every line's format and checksum.
 
template<typename Source>
static void referenceFrame (Reference &teleInfo)
 The frame of sendTelemetryData() as it was, N and V sent unsigned.
 
void setUp (void)
 
template<typename Source>
static Streamed streamFrame ()
 
void tearDown (void)
 
void test_absence_count_unsigned (void)
 
void test_every_tag (void)
 
void test_golden_frame (void)
 
void test_line (void)
 
void test_one_line_per_step (void)
 
void test_optional_features (void)
 
void test_sample_count_unsigned (void)
 
void test_step_fits_serial_output (void)
 
void test_streamed_frame_equals_buffered (void)
 
void test_voltage_unsigned (void)
 
static void typicalValues ()
 A datalog with every value set, temperature 2 invalid.
 
static const char * valueOf (const Line(&lines)[32], uint8_t count, const char *tag)
 The value of the line with exactly this tag.
 

Variables

static Values values
 

Detailed Description

Native tests for teleinfo.h: the IoT frame, streamed a line per step.

The frame is written by TeleInfo::writeFrameStep(), one line per step of the serial output (STX before the first line, ETX after the last), from a data source: here, test sources with feature sets of the firmware. It must give, byte for byte, what the buffered TeleInfo class of the firmware wrote before (Reference below, its code kept as it was, utoa() replaced by snprintf()), with N and V sent unsigned.

Definition in file test_main.cpp.

Typedef Documentation

◆ Default

using Default = TestSource< 3, 0, 3, 0, false >

Definition at line 318 of file test_main.cpp.

◆ DualTariff

using DualTariff = TestSource< 3, 0, 3, 0, true >

Definition at line 321 of file test_main.cpp.

◆ Everything

using Everything = TestSource< 3, 2, 4, 4, true >

Definition at line 322 of file test_main.cpp.

◆ Minimal

using Minimal = TestSource< 3, 0, 1, 0, false >

Definition at line 317 of file test_main.cpp.

◆ Relays

using Relays = TestSource< 3, 2, 3, 0, false >

Definition at line 319 of file test_main.cpp.

◆ SinglePhase

using SinglePhase = TestSource< 1, 0, 1, 0, false >

Definition at line 316 of file test_main.cpp.

◆ Temperatures

using Temperatures = TestSource< 3, 0, 3, 2, false >

Definition at line 320 of file test_main.cpp.

Function Documentation

◆ assertSameAsReference()

template<typename Source>
static void assertSameAsReference ( const char * message)
static

Definition at line 294 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ countTag()

static uint8_t countTag ( const Line(&) lines[32],
uint8_t count,
const char * tag )
static

How many lines have exactly this tag.

Definition at line 466 of file test_main.cpp.

Here is the caller graph for this function:

◆ extremeValues()

static void extremeValues ( )
static

The extremes of every value.

Definition at line 311 of file test_main.cpp.

Here is the caller graph for this function:

◆ main()

int main ( int ,
char **  )

Definition at line 638 of file test_main.cpp.

Here is the call graph for this function:

◆ parseFrame()

static uint8_t parseFrame ( const Streamed & frame,
Line(&) lines[32] )
static

Splits a frame into its lines, as a receiver does, checking STX, ETX and every line's format and checksum.

Returns
the number of lines

Definition at line 431 of file test_main.cpp.

Here is the caller graph for this function:

◆ referenceFrame()

template<typename Source>
static void referenceFrame ( Reference & teleInfo)
static

The frame of sendTelemetryData() as it was, N and V sent unsigned.

Definition at line 202 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUp()

void setUp ( void )

Definition at line 21 of file test_main.cpp.

◆ streamFrame()

template<typename Source>
static Streamed streamFrame ( )
static

Definition at line 272 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tearDown()

void tearDown ( void )

Definition at line 22 of file test_main.cpp.

◆ test_absence_count_unsigned()

void test_absence_count_unsigned ( void )

Definition at line 567 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_every_tag()

void test_every_tag ( void )

Definition at line 490 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_golden_frame()

void test_golden_frame ( void )

Definition at line 373 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_line()

void test_line ( void )

Definition at line 612 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_one_line_per_step()

void test_one_line_per_step ( void )

Definition at line 361 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_optional_features()

void test_optional_features ( void )

Definition at line 528 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_sample_count_unsigned()

void test_sample_count_unsigned ( void )

Definition at line 601 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_step_fits_serial_output()

void test_step_fits_serial_output ( void )

Definition at line 351 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_streamed_frame_equals_buffered()

void test_streamed_frame_equals_buffered ( void )

Definition at line 325 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_voltage_unsigned()

void test_voltage_unsigned ( void )

Definition at line 584 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ typicalValues()

static void typicalValues ( )
static

A datalog with every value set, temperature 2 invalid.

Definition at line 305 of file test_main.cpp.

Here is the caller graph for this function:

◆ valueOf()

static const char * valueOf ( const Line(&) lines[32],
uint8_t count,
const char * tag )
static

The value of the line with exactly this tag.

Definition at line 477 of file test_main.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ values

Values values
static

Definition at line 41 of file test_main.cpp.