VecLen
- Macro
- August 22, 2025
Table of Contents
VecLen
VecLen
Description
Length of vector.
Parameters
Name | Direction | Description |
---|---|---|
v | in | Vector to get length of |
Usage example (Cross-references)
});
if (VecLen(&items) == 0) {
printf("[DEBUG] Empty array test passed - no items added\n");
} else {
printf("[DEBUG] Empty array test passed - no items added\n");
} else {
printf("[DEBUG] Empty array test FAILED - %zu items found\n", VecLen(&items));
success = false;
}
});
if (VecLen(&data) == 0) {
printf("[DEBUG] Empty array with whitespace test passed\n");
} else {
});
if (obj.x_value == 1 && VecLen(&obj.filled_items) == 2 && VecAt(&obj.filled_items, 0) == 1 &&
VecAt(&obj.filled_items, 1) == 2) {
printf(
"[DEBUG] Mixed empty and filled test passed - x: %d, items: %zu\n",
obj.x_value,
VecLen(&obj.filled_items)
);
} else {
"[DEBUG] Mixed empty and filled test FAILED - x: %d, items: %zu\n",
obj.x_value,
VecLen(&obj.filled_items)
);
if (VecLen(&obj.filled_items) > 0) {
VecLen(&obj.filled_items)
);
if (VecLen(&obj.filled_items) > 0) {
printf("[DEBUG] First item: %d\n", VecAt(&obj.filled_items, 0));
}
- In
RoundTrip.c:72
:
bool compare_configs(const TestConfig* a, const TestConfig* b) {
if (a->debug_mode != b->debug_mode || a->timeout != b->timeout || StrCmp(&a->log_level, &b->log_level) != 0 ||
VecLen(&a->features) != VecLen(&b->features)) {
return false;
}
- In
RoundTrip.c:76
:
}
for (size i = 0; i < VecLen(&a->features); i++) {
if (StrCmp(&VecAt(&a->features, i), &VecAt(&b->features, i)) != 0) {
return false;
- In
RoundTrip.c:398
:
// Compare arrays
bool numbers_match = (VecLen(&original_numbers) == VecLen(&parsed_numbers));
if (numbers_match) {
for (size i = 0; i < VecLen(&original_numbers); i++) {
- In
RoundTrip.c:400
:
bool numbers_match = (VecLen(&original_numbers) == VecLen(&parsed_numbers));
if (numbers_match) {
for (size i = 0; i < VecLen(&original_numbers); i++) {
if (VecAt(&original_numbers, i) != VecAt(&parsed_numbers, i)) {
numbers_match = false;
- In
RoundTrip.c:408
:
}
bool strings_match = (VecLen(&original_strings) == VecLen(&parsed_strings));
if (strings_match) {
for (size i = 0; i < VecLen(&original_strings); i++) {
- In
RoundTrip.c:410
:
bool strings_match = (VecLen(&original_strings) == VecLen(&parsed_strings));
if (strings_match) {
for (size i = 0; i < VecLen(&original_strings); i++) {
if (VecAt(&original_strings, i).length != VecAt(&parsed_strings, i).length ||
(VecAt(&original_strings, i).length &&
- In
RoundTrip.c:427
:
"[DEBUG] Numbers match: %s (orig %zu, parsed %zu)\n",
numbers_match ? "true" : "false",
VecLen(&original_numbers),
VecLen(&parsed_numbers)
);
- In
RoundTrip.c:428
:
numbers_match ? "true" : "false",
VecLen(&original_numbers),
VecLen(&parsed_numbers)
);
printf(
- In
RoundTrip.c:433
:
"[DEBUG] Strings match: %s (orig %zu, parsed %zu)\n",
strings_match ? "true" : "false",
VecLen(&original_strings),
VecLen(&parsed_strings)
);
- In
RoundTrip.c:434
:
strings_match ? "true" : "false",
VecLen(&original_strings),
VecLen(&parsed_strings)
);
success = false;
- In
RoundTrip.c:603
:
bool config_match = compare_configs(&original.config, &parsed.config);
bool numbers_match = (VecLen(&original.numbers) == VecLen(&parsed.numbers));
if (numbers_match) {
for (size i = 0; i < VecLen(&original.numbers); i++) {
- In
RoundTrip.c:605
:
bool numbers_match = (VecLen(&original.numbers) == VecLen(&parsed.numbers));
if (numbers_match) {
for (size i = 0; i < VecLen(&original.numbers); i++) {
if (VecAt(&original.numbers, i) != VecAt(&parsed.numbers, i)) {
numbers_match = false;
- In
RoundTrip.c:613
:
}
bool flags_match = (VecLen(&original.flags) == VecLen(&parsed.flags));
if (flags_match) {
for (size i = 0; i < VecLen(&original.flags); i++) {
- In
RoundTrip.c:615
:
bool flags_match = (VecLen(&original.flags) == VecLen(&parsed.flags));
if (flags_match) {
for (size i = 0; i < VecLen(&original.flags); i++) {
if (VecAt(&original.flags, i) != VecAt(&parsed.flags, i)) {
flags_match = false;
- In
RoundTrip.c:690
:
// Compare empty containers
if (parsed_str.length == 0 && VecLen(&parsed_numbers) == 0 && VecLen(&parsed_strings) == 0 &&
!found_empty_object) { // Empty object should not execute the content
printf("[DEBUG] Empty containers round-trip test passed\n");
- In
RoundTrip.c:698
:
"[DEBUG] String length: %zu, numbers: %zu, strings: %zu, found_obj: %s\n",
parsed_str.length,
VecLen(&parsed_numbers),
VecLen(&parsed_strings),
found_empty_object ? "true" : "false"
- In
RoundTrip.c:699
:
parsed_str.length,
VecLen(&parsed_numbers),
VecLen(&parsed_strings),
found_empty_object ? "true" : "false"
);
- In
Vec.Access.c:149
:
// Test VecSize and VecLen functions
bool test_vec_size_len(void) {
printf("Testing VecSize and VecLen\n");
// Create a vector of integers
- In
Vec.Access.c:157
:
// Check initial size and length
size vec_size = VecSize(&vec);
size vec_len = VecLen(&vec);
bool result = (vec_size == 0);
result = result && (vec_len == 0);
- In
Vec.Access.c:168
:
// Check size and length after adding elements
vec_size = VecSize(&vec);
vec_len = VecLen(&vec);
size aligned_offset = VecAlignedOffsetAt(&vec, vec.length);
result = result && (vec_size == aligned_offset);
- In
Vec.Access.c:186
:
// Check size and length with alignment
size aligned_vec_size = VecSize(&aligned_vec);
size aligned_vec_len = VecLen(&aligned_vec);
size aligned_offset_at = VecAlignedOffsetAt(&aligned_vec, aligned_vec.length);
result = result && (aligned_vec_size == aligned_offset_at);