Coverage Report

Created: 2026-08-17 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/sbi/openapi/model/radial_velocity.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "radial_velocity.h"
6
7
OpenAPI_radial_velocity_t *OpenAPI_radial_velocity_create(
8
    OpenAPI_units_linear_velocity_e units_radial_velocity,
9
    int radial_velocity,
10
    int r_velocity_uncertainty
11
)
12
0
{
13
0
    OpenAPI_radial_velocity_t *radial_velocity_local_var = ogs_malloc(sizeof(OpenAPI_radial_velocity_t));
14
0
    ogs_assert(radial_velocity_local_var);
15
16
0
    radial_velocity_local_var->units_radial_velocity = units_radial_velocity;
17
0
    radial_velocity_local_var->radial_velocity = radial_velocity;
18
0
    radial_velocity_local_var->r_velocity_uncertainty = r_velocity_uncertainty;
19
20
0
    return radial_velocity_local_var;
21
0
}
22
23
void OpenAPI_radial_velocity_free(OpenAPI_radial_velocity_t *radial_velocity)
24
0
{
25
0
    OpenAPI_lnode_t *node = NULL;
26
27
0
    if (NULL == radial_velocity) {
28
0
        return;
29
0
    }
30
0
    ogs_free(radial_velocity);
31
0
}
32
33
cJSON *OpenAPI_radial_velocity_convertToJSON(OpenAPI_radial_velocity_t *radial_velocity)
34
0
{
35
0
    cJSON *item = NULL;
36
0
    OpenAPI_lnode_t *node = NULL;
37
38
0
    if (radial_velocity == NULL) {
39
0
        ogs_error("OpenAPI_radial_velocity_convertToJSON() failed [RadialVelocity]");
40
0
        return NULL;
41
0
    }
42
43
0
    item = cJSON_CreateObject();
44
0
    if (radial_velocity->units_radial_velocity == OpenAPI_units_linear_velocity_NULL) {
45
0
        ogs_error("OpenAPI_radial_velocity_convertToJSON() failed [units_radial_velocity]");
46
0
        return NULL;
47
0
    }
48
0
    if (cJSON_AddStringToObject(item, "unitsRadialVelocity", OpenAPI_units_linear_velocity_ToString(radial_velocity->units_radial_velocity)) == NULL) {
49
0
        ogs_error("OpenAPI_radial_velocity_convertToJSON() failed [units_radial_velocity]");
50
0
        goto end;
51
0
    }
52
53
0
    if (cJSON_AddNumberToObject(item, "radialVelocity", radial_velocity->radial_velocity) == NULL) {
54
0
        ogs_error("OpenAPI_radial_velocity_convertToJSON() failed [radial_velocity]");
55
0
        goto end;
56
0
    }
57
58
0
    if (cJSON_AddNumberToObject(item, "rVelocityUncertainty", radial_velocity->r_velocity_uncertainty) == NULL) {
59
0
        ogs_error("OpenAPI_radial_velocity_convertToJSON() failed [r_velocity_uncertainty]");
60
0
        goto end;
61
0
    }
62
63
0
end:
64
0
    return item;
65
0
}
66
67
OpenAPI_radial_velocity_t *OpenAPI_radial_velocity_parseFromJSON(cJSON *radial_velocityJSON)
68
0
{
69
0
    OpenAPI_radial_velocity_t *radial_velocity_local_var = NULL;
70
0
    OpenAPI_lnode_t *node = NULL;
71
0
    cJSON *units_radial_velocity = NULL;
72
0
    OpenAPI_units_linear_velocity_e units_radial_velocityVariable = 0;
73
0
    cJSON *radial_velocity = NULL;
74
0
    cJSON *r_velocity_uncertainty = NULL;
75
0
    units_radial_velocity = cJSON_GetObjectItemCaseSensitive(radial_velocityJSON, "unitsRadialVelocity");
76
0
    if (!units_radial_velocity) {
77
0
        ogs_error("OpenAPI_radial_velocity_parseFromJSON() failed [units_radial_velocity]");
78
0
        goto end;
79
0
    }
80
0
    if (!cJSON_IsString(units_radial_velocity)) {
81
0
        ogs_error("OpenAPI_radial_velocity_parseFromJSON() failed [units_radial_velocity]");
82
0
        goto end;
83
0
    }
84
0
    units_radial_velocityVariable = OpenAPI_units_linear_velocity_FromString(units_radial_velocity->valuestring);
85
86
0
    radial_velocity = cJSON_GetObjectItemCaseSensitive(radial_velocityJSON, "radialVelocity");
87
0
    if (!radial_velocity) {
88
0
        ogs_error("OpenAPI_radial_velocity_parseFromJSON() failed [radial_velocity]");
89
0
        goto end;
90
0
    }
91
0
    if (!cJSON_IsNumber(radial_velocity)) {
92
0
        ogs_error("OpenAPI_radial_velocity_parseFromJSON() failed [radial_velocity]");
93
0
        goto end;
94
0
    }
95
96
0
    r_velocity_uncertainty = cJSON_GetObjectItemCaseSensitive(radial_velocityJSON, "rVelocityUncertainty");
97
0
    if (!r_velocity_uncertainty) {
98
0
        ogs_error("OpenAPI_radial_velocity_parseFromJSON() failed [r_velocity_uncertainty]");
99
0
        goto end;
100
0
    }
101
0
    if (!cJSON_IsNumber(r_velocity_uncertainty)) {
102
0
        ogs_error("OpenAPI_radial_velocity_parseFromJSON() failed [r_velocity_uncertainty]");
103
0
        goto end;
104
0
    }
105
106
0
    radial_velocity_local_var = OpenAPI_radial_velocity_create (
107
0
        units_radial_velocityVariable,
108
        
109
0
        radial_velocity->valuedouble,
110
        
111
0
        r_velocity_uncertainty->valuedouble
112
0
    );
113
114
0
    return radial_velocity_local_var;
115
0
end:
116
0
    return NULL;
117
0
}
118
119
OpenAPI_radial_velocity_t *OpenAPI_radial_velocity_copy(OpenAPI_radial_velocity_t *dst, OpenAPI_radial_velocity_t *src)
120
0
{
121
0
    cJSON *item = NULL;
122
0
    char *content = NULL;
123
124
0
    ogs_assert(src);
125
0
    item = OpenAPI_radial_velocity_convertToJSON(src);
126
0
    if (!item) {
127
0
        ogs_error("OpenAPI_radial_velocity_convertToJSON() failed");
128
0
        return NULL;
129
0
    }
130
131
0
    content = cJSON_Print(item);
132
0
    cJSON_Delete(item);
133
134
0
    if (!content) {
135
0
        ogs_error("cJSON_Print() failed");
136
0
        return NULL;
137
0
    }
138
139
0
    item = cJSON_Parse(content);
140
0
    ogs_free(content);
141
0
    if (!item) {
142
0
        ogs_error("cJSON_Parse() failed");
143
0
        return NULL;
144
0
    }
145
146
0
    OpenAPI_radial_velocity_free(dst);
147
0
    dst = OpenAPI_radial_velocity_parseFromJSON(item);
148
0
    cJSON_Delete(item);
149
150
0
    return dst;
151
0
}
152