• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nasa / trick / 28043225380

23 Jun 2026 05:08PM UTC coverage: 56.232% (+0.1%) from 56.126%
28043225380

Pull #2154

github

web-flow
Merge 4f3015579 into 4a137dd0c
Pull Request #2154: Add data recording support for STL (vector, deque, and array) of supported data types.

120 of 145 new or added lines in 5 files covered. (82.76%)

2 existing lines in 1 file now uncovered.

14722 of 26181 relevant lines covered (56.23%)

470774.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/trick_source/sim_services/MemoryManager/ReferenceUtils.cpp
1
#include "trick/ReferenceUtils.hh"
2

3
#include <string.h>
4

5
// Returns the size in bytes of the element type for an STL container.
6
// For example, for a std::vector<int>, it would return sizeof(int).
7
static size_t stl_elem_type_size(TRICK_TYPE elem_type)
589✔
8
{
9
    switch (elem_type)
589✔
10
    {
NEW
11
    case TRICK_CHARACTER:
×
12
    case TRICK_UNSIGNED_CHARACTER:
13
    case TRICK_BOOLEAN:
NEW
14
        return sizeof(char);
×
NEW
15
    case TRICK_SHORT:
×
16
    case TRICK_UNSIGNED_SHORT:
NEW
17
        return sizeof(short);
×
18
    case TRICK_INTEGER:
295✔
19
    case TRICK_UNSIGNED_INTEGER:
20
    case TRICK_ENUMERATED:
21
        return sizeof(int);
295✔
NEW
22
    case TRICK_LONG:
×
23
    case TRICK_UNSIGNED_LONG:
NEW
24
        return sizeof(long);
×
NEW
25
    case TRICK_LONG_LONG:
×
26
    case TRICK_UNSIGNED_LONG_LONG:
NEW
27
        return sizeof(long long);
×
28
    case TRICK_FLOAT:
147✔
29
        return sizeof(float);
147✔
30
    case TRICK_DOUBLE:
147✔
31
        return sizeof(double);
147✔
NEW
32
    case TRICK_STRING:
×
33
    case TRICK_WSTRING:
34
    case TRICK_STRUCTURED:
NEW
35
        return sizeof(void*);
×
NEW
36
    default:
×
NEW
37
        return 0;
×
38
    }
39
}
40

41
// Check if a reference is to an STL container element.
42
// Returns true if the reference points to an element within an STL container, false otherwise.
43
bool Trick::ReferenceUtils::is_stl_ref(const REF2* ref)
8,686✔
44
{
45
    if (!ref || !ref->attr)
8,686✔
NEW
46
        return false;
×
47
    if (ref->stl_present == 1)
8,686✔
48
        return true;
57✔
49
    if (ref->attr->type == TRICK_STL && ref->reference)
8,629✔
50
    {
51
        size_t len = strlen(ref->reference);
1✔
52
        return (len > 0 && ref->reference[len - 1] == ']');
1✔
53
    }
54
    return false;
8,628✔
55
}
56

57
// Determine the effective Trick type of a reference.
58
// If the reference points to an element within an STL container, return the element type.
59
// Otherwise, return the type of the attribute itself.
60
TRICK_TYPE Trick::ReferenceUtils::effective_trick_type(const REF2* ref)
34,910,758✔
61
{
62
    if (!ref || !ref->attr)
34,910,758✔
NEW
63
        return TRICK_NUMBER_OF_TYPES;
×
64
    if (ref->attr->type == TRICK_STL && ref->reference)
34,910,758✔
65
    {
66
        size_t len = strlen(ref->reference);
326✔
67
        if (len > 0 && ref->reference[len - 1] == ']')
326✔
68
            return ref->attr->stl_elem_type;
325✔
69
    }
70
    return ref->attr->type;
34,910,433✔
71
}
72

73
// Determine the effective size of a reference.
74
// If the reference points to an element within an STL container, return the size of the element type.
75
// Otherwise, return the size of the attribute itself.
76
size_t Trick::ReferenceUtils::effective_trick_size(const REF2* ref)
69,803,688✔
77
{
78
    if (!ref || !ref->attr)
69,803,688✔
NEW
79
        return 0;
×
80
    if (ref->attr->type == TRICK_STL && ref->reference)
69,803,688✔
81
    {
82
        size_t len = strlen(ref->reference);
589✔
83
        if (len > 0 && ref->reference[len - 1] == ']')
589✔
84
            return stl_elem_type_size(ref->attr->stl_elem_type);
589✔
85
    }
86
    return (size_t)ref->attr->size;
69,803,099✔
87
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc