core: add constructor/destructor pairs to dive and divecomputer

This allows us to use non-C member variables. Convert a number
of pointers to unique_ptr<>s.

Code in uemis-downloader.cpp had to be refactored, because
it mixed owning and non-owning pointers. Mad.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-16 20:11:21 +02:00 committed by bstoeger
parent bfb54aa581
commit cc39f709ce
35 changed files with 289 additions and 308 deletions

View file

@ -9,14 +9,14 @@ void TestformatDiveGasString::init()
void TestformatDiveGasString::test_empty()
{
struct dive dive = {0};
struct dive dive;
QCOMPARE(formatDiveGasString(&dive), "air");
}
void TestformatDiveGasString::test_air()
{
struct dive dive = {0};
struct dive dive;
cylinder_t *cylinder = get_or_create_cylinder(&dive, 0);
cylinder->start.mbar = 230000;
@ -25,8 +25,9 @@ void TestformatDiveGasString::test_air()
QCOMPARE(formatDiveGasString(&dive), "air");
}
void TestformatDiveGasString::test_nitrox() {
struct dive dive = {0};
void TestformatDiveGasString::test_nitrox()
{
struct dive dive;
cylinder_t *cylinder = get_or_create_cylinder(&dive, 0);
cylinder->gasmix.o2.permille = 320;
@ -36,8 +37,9 @@ void TestformatDiveGasString::test_nitrox() {
QCOMPARE(formatDiveGasString(&dive), "32%");
}
void TestformatDiveGasString::test_nitrox_not_use() {
struct dive dive = {0};
void TestformatDiveGasString::test_nitrox_not_use()
{
struct dive dive;
cylinder_t *cylinder = get_or_create_cylinder(&dive, 0);
cylinder->gasmix.o2.permille = 320;
@ -54,8 +56,9 @@ void TestformatDiveGasString::test_nitrox_not_use() {
QCOMPARE(formatDiveGasString(&dive), "32%");
}
void TestformatDiveGasString::test_nitrox_deco() {
struct dive dive = {0};
void TestformatDiveGasString::test_nitrox_deco()
{
struct dive dive;
cylinder_t *cylinder = get_or_create_cylinder(&dive, 0);
cylinder->gasmix.o2.permille = 320;
@ -71,8 +74,9 @@ void TestformatDiveGasString::test_nitrox_deco() {
QCOMPARE(formatDiveGasString(&dive), "32…100%");
}
void TestformatDiveGasString::test_reverse_nitrox_deco() {
struct dive dive = {0};
void TestformatDiveGasString::test_reverse_nitrox_deco()
{
struct dive dive;
cylinder_t *cylinder = get_or_create_cylinder(&dive, 0);
cylinder->gasmix.o2.permille = 1000;
@ -88,8 +92,9 @@ void TestformatDiveGasString::test_reverse_nitrox_deco() {
QCOMPARE(formatDiveGasString(&dive), "27…100%");
}
void TestformatDiveGasString::test_trimix() {
struct dive dive = {0};
void TestformatDiveGasString::test_trimix()
{
struct dive dive;
cylinder_t *cylinder = get_or_create_cylinder(&dive, 0);
cylinder->gasmix.o2.permille = 210;
@ -100,8 +105,9 @@ void TestformatDiveGasString::test_trimix() {
QCOMPARE(formatDiveGasString(&dive), "21/35");
}
void TestformatDiveGasString::test_trimix_deco() {
struct dive dive = {0};
void TestformatDiveGasString::test_trimix_deco()
{
struct dive dive;
cylinder_t *cylinder = get_or_create_cylinder(&dive, 0);
cylinder->gasmix.o2.permille = 210;
@ -125,8 +131,9 @@ void TestformatDiveGasString::test_trimix_deco() {
QCOMPARE(formatDiveGasString(&dive), "21/35…100%");
}
void TestformatDiveGasString::test_reverse_trimix_deco() {
struct dive dive = {0};
void TestformatDiveGasString::test_reverse_trimix_deco()
{
struct dive dive;
cylinder_t *cylinder = get_or_create_cylinder(&dive, 0);
cylinder->gasmix.o2.permille = 1000;
@ -150,8 +157,9 @@ void TestformatDiveGasString::test_reverse_trimix_deco() {
QCOMPARE(formatDiveGasString(&dive), "21/35…100%");
}
void TestformatDiveGasString::test_trimix_and_nitrox_same_o2() {
struct dive dive = {0};
void TestformatDiveGasString::test_trimix_and_nitrox_same_o2()
{
struct dive dive;
cylinder_t *cylinder = get_or_create_cylinder(&dive, 0);
cylinder->gasmix.o2.permille = 250;
@ -169,8 +177,9 @@ void TestformatDiveGasString::test_trimix_and_nitrox_same_o2() {
QCOMPARE(formatDiveGasString(&dive), "25/25");
}
void TestformatDiveGasString::test_trimix_and_nitrox_lower_o2() {
struct dive dive = {0};
void TestformatDiveGasString::test_trimix_and_nitrox_lower_o2()
{
struct dive dive;
cylinder_t *cylinder = get_or_create_cylinder(&dive, 0);
cylinder->gasmix.o2.permille = 220;
@ -188,8 +197,9 @@ void TestformatDiveGasString::test_trimix_and_nitrox_lower_o2() {
QCOMPARE(formatDiveGasString(&dive), "25/25");
}
void TestformatDiveGasString::test_ccr() {
struct dive dive = {0};
void TestformatDiveGasString::test_ccr()
{
struct dive dive;
cylinder_t *cylinder = get_or_create_cylinder(&dive, 0);
cylinder->gasmix.o2.permille = 1000;
@ -208,8 +218,9 @@ void TestformatDiveGasString::test_ccr() {
QCOMPARE(formatDiveGasString(&dive), "21/35");
}
void TestformatDiveGasString::test_ccr_bailout() {
struct dive dive = {0};
void TestformatDiveGasString::test_ccr_bailout()
{
struct dive dive;
cylinder_t *cylinder = get_or_create_cylinder(&dive, 0);
cylinder->gasmix.o2.permille = 1000;