Skip to content

profile_test.cpp

file tests/io/profile_test.cpp · Test suite

Tests of nmeasim::io::Profile: its JSON form, validation, schema migration and files.

Source tests/io/profile_test.cpp

Covers Profile::default_profile, the round trip through Profile::to_json and Profile::from_json for every setting and output type, the defaults that fill in missing keys, the rejection of invalid documents with a reason that names the offending key, the migration of schema versions 1 and 2 to the current version 3, Profile::save and Profile::load with relative paths and Profile::resolve_path, Profile::make_scheduler, and the string names of output types, simulation modes and encodings.

The profiles are built in code or saved to temporary directories; the file reads no fixture. The track and log paths it sets are never opened.

Test cases

18 test cases, in source order.

Test case Tags
the default profile is valid and round-trips through JSON [io][profile]
sentence settings, start time and every output type round-trip [io][profile]
missing fields fall back to defaults [io][profile]
invalid profiles are rejected with a reason [io][profile]
a destination needs a position and unknown GNSS qualities are rejected [io][profile]
sentence settings are validated [io][profile]
profiles are saved to and loaded from disk [io][profile]
output types have stable names [io][profile]
track and replay modes round-trip with their settings [io][profile]
schema version 1 profiles are migrated to the current version [io][profile]
mode settings are validated [io][profile]
output settings are validated for the types that use them [io][profile]
relative track and log paths are resolved against the profile file [io][profile]
destination, AIS data, custom sentences and encodings round-trip [io][profile]
schema version 2 profiles load with the new defaults [io][profile]
the new schema 3 keys are validated [io][profile]
custom sentence ids must be unique [io][profile]
random seed, MMSI and IMO number outside their integer range are rejected [io][profile]

Summary

File-local enumerations

Name Description
SimulationMode What drives the vessel, the simulation.mode key of a profile.

File-local enumerations

SimulationMode

enum class SimulationMode

What drives the vessel, the simulation.mode key of a profile.

Each enumerator is written as the string given in its description; to_string and simulation_mode_from_string convert. In every mode the delta seed supplies the values the driving source does not.

Declared in tests/io/profile_test.cpp:33 · defined in src/io/include/nmeasim/io/profile/profile.hpp:206