PX4 Firmware
PX4 Autopilot Software http://px4.io
test_bson.cpp File Reference

Tests for the bson en/decoder. More...

#include <inttypes.h>
#include <px4_platform_common/defines.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <systemlib/err.h>
#include <parameters/tinybson/tinybson.h>
#include "tests_main.h"
Include dependency graph for test_bson.cpp:

Go to the source code of this file.

Functions

static int encode (bson_encoder_t encoder)
 
static int decode_callback (bson_decoder_t decoder, void *priv, bson_node_t node)
 
static void decode (bson_decoder_t decoder)
 
int test_bson (int argc, char *argv[])
 

Variables

static const bool sample_bool = true
 
static const int32_t sample_small_int = 123
 
static const int64_t sample_big_int = (int64_t)INT_MAX + 123LL
 
static const double sample_double = 2.5f
 
static const char * sample_string = "this is a test"
 
static const uint8_t sample_data [256] = {0}
 

Detailed Description

Tests for the bson en/decoder.

Definition in file test_bson.cpp.

Function Documentation

◆ decode()

static void decode ( bson_decoder_t  decoder)
static

Definition at line 252 of file test_bson.cpp.

References bson_decoder_next().

Referenced by sbus_decode(), and test_bson().

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

◆ decode_callback()

static int decode_callback ( bson_decoder_t  decoder,
void *  priv,
bson_node_t  node 
)
static

Definition at line 100 of file test_bson.cpp.

References bson_node_s::b, BSON_BIN_BINARY, BSON_BINDATA, BSON_BOOL, bson_decoder_copy_data(), bson_decoder_data_pending(), BSON_DOUBLE, BSON_EOO, BSON_INT32, BSON_INT64, BSON_STRING, bson_node_s::d, bson_node_s::i, bson_node_s::name, sample_big_int, sample_bool, sample_data, sample_double, sample_small_int, sample_string, bson_node_s::subtype, bson_node_s::type, and warnx.

Referenced by test_bson().

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

◆ encode()

static int encode ( bson_encoder_t  encoder)
static

Definition at line 62 of file test_bson.cpp.

References BSON_BIN_BINARY, bson_encoder_append_binary(), bson_encoder_append_bool(), bson_encoder_append_double(), bson_encoder_append_int(), bson_encoder_append_string(), bson_encoder_fini(), sample_big_int, sample_bool, sample_data, sample_double, sample_small_int, and sample_string.

Referenced by test_bson().

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

◆ test_bson()

int test_bson ( int  argc,
char *  argv[] 
)

Definition at line 262 of file test_bson.cpp.

References bson_decoder_init_buf(), bson_encoder_buf_data(), bson_encoder_buf_size(), bson_encoder_init_buf(), bson_decoder_s::buf, decode(), decode_callback(), and encode().

Here is the call graph for this function:

Variable Documentation

◆ sample_big_int

const int64_t sample_big_int = (int64_t)INT_MAX + 123LL
static

Definition at line 55 of file test_bson.cpp.

Referenced by decode_callback(), and encode().

◆ sample_bool

const bool sample_bool = true
static

Definition at line 53 of file test_bson.cpp.

Referenced by decode_callback(), and encode().

◆ sample_data

const uint8_t sample_data[256] = {0}
static

Definition at line 58 of file test_bson.cpp.

Referenced by decode_callback(), and encode().

◆ sample_double

const double sample_double = 2.5f
static

Definition at line 56 of file test_bson.cpp.

Referenced by decode_callback(), and encode().

◆ sample_small_int

const int32_t sample_small_int = 123
static

Definition at line 54 of file test_bson.cpp.

Referenced by decode_callback(), and encode().

◆ sample_string

const char* sample_string = "this is a test"
static

Definition at line 57 of file test_bson.cpp.

Referenced by decode_callback(), and encode().