Publish VCC Plus OSS source distribution for 3.6.2 build 60

This commit is contained in:
Brian Holman committed 2026-11-13 00:14:03 -07:00
commit c652a5276d
1192 files changed
+272368

No files matched your search

@@ -0,0 +1,67 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include <cmoc.h>
#include <vcc/decimal.h>
struct Vector {
unsigned char packed[5];
unsigned char places;
const char *expected; // NULL marks an out-of-range value.
};
static const struct Vector vectors[] = {
#include "vectors.inc"
};
static unsigned index;
static int check(void)
{
char storage[16];
char *out = storage + 1;
float value;
if (sizeof(value) != 5)
return __LINE__;
for (index = 0; index < sizeof(vectors) / sizeof(vectors[0]); ++index) {
const struct Vector *test = vectors + index;
const char *expected = test->expected;
int wanted = expected ? (int) strlen(expected) : -1;
memcpy(&value, test->packed, sizeof(value));
if (vcc_fixed(NULL, 0, value, test->places) != wanted)
return __LINE__;
// Each short capacity, exact fit and spare capacity. Compare both
// sentinels and all bytes beyond the output (also when capacity is 0).
unsigned capacity;
for (capacity = 0; capacity <= (unsigned)(wanted < 0 ? 3 : wanted + 2); ++capacity) {
memset(storage, '@', sizeof(storage));
if (vcc_fixed(out, capacity, value, test->places) != wanted)
return __LINE__;
unsigned used = 0;
if (capacity) {
unsigned prefix = expected ? (unsigned) wanted : 0u;
if (prefix >= capacity)
prefix = capacity - 1;
if ((prefix && memcmp(out, expected, prefix)) || out[prefix])
return __LINE__;
used = prefix + 1;
}
if (storage[0] != '@')
return __LINE__;
while (used < sizeof(storage) - 1)
if (out[used++] != '@')
return __LINE__;
}
}
if (vcc_fixed(NULL, 1, 1.0f, 3) != -1)
return __LINE__;
return 0;
}
int main(void)
{
int failure = check();
if (failure)
printf("FAIL LINE %d CASE %u\n", failure, index);
else
printf("DECIMAL CHECKS PASSED\n");
return failure != 0;
}