Last changes

This commit is contained in:
Leonardo Vencovsky committed 2023-02-22 15:09:16 +01:00
1 parent b330790bf9
commit 6f8496d39e
3 files changed
+83

No files matched your search

+16
View File
@@ -43,6 +43,7 @@
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/**
@@ -124,6 +125,11 @@ static inline int cmc_double_cmp(double x1, double x2)
// String
static inline int cmc_chr_cmp(char ch1, char ch2)
{
return (ch1 > ch2) - (ch1 < ch2);
}
static inline int cmc_str_cmp(char *ch1, char *ch2)
{
// Assuming ch1 and ch2 are both null terminated character sequences
@@ -227,6 +233,11 @@ static inline bool cmc_double_str(FILE *file, double element)
// String
static inline bool cmc_chr_chr(FILE *file, char element)
{
return fprintf(file, "%c", element) > 0;
}
static inline bool cmc_str_str(FILE *file, char *element)
{
return fprintf(file, "\"%s\"", element) > 0;
@@ -380,6 +391,11 @@ static inline size_t cmc_double_hash(double e)
// String
static inline size_t cmc_chr_hash(char e)
{
return cmc_u8_hash((uint8_t)e);
}
// Both djb2 and java are based on a Linear Congruential Generator
// https://en.wikipedia.org/wiki/Linear_congruential_generator
+4
View File
@@ -13,6 +13,10 @@ dev: main
mkdir -p ./coverage
mv *.gcov ./coverage
single:
$(CC) ./single.c $(INCLUDE) $(CFLAGS) -o ./$(OUTDIR)/$@.exe -DTEST=$(TEST)
./$(OUTDIR)/$@.exe
clean:
rm ./*.gcov ./*.gcda ./*.gcno ./*.exe -f
rm ./coverage ./$(OUTDIR) -rf
+63
View File
@@ -0,0 +1,63 @@
#include <inttypes.h>
#include <stdio.h>
#include "cmc/utl/log.h"
#define CMC_ARGS_FALLTHROUGH
#define CMC_EXT_INIT
#define CMC_EXT_ITER
#define CMC_EXT_NODE
#define CMC_EXT_SEQ
#define CMC_EXT_SETF
#define CMC_EXT_STR
#include "unt_bitset.h"
#include "unt_deque.h"
#include "unt_hashbidimap.h"
#include "unt_hashmap.h"
#include "unt_hashmultimap.h"
#include "unt_hashmultiset.h"
#include "unt_hashset.h"
#include "unt_heap.h"
#include "unt_intervalheap.h"
#include "unt_linkedlist.h"
#include "unt_list.h"
#include "unt_queue.h"
#include "unt_sortedlist.h"
#include "unt_stack.h"
#include "unt_treemap.h"
#include "unt_treeset.h"
#define cmc_run(unit, unit_fails, test_fails) \
do \
{ \
uintmax_t f = unit(); \
if (f != 0) \
unit_fails += 1; \
test_fails += f; \
} while (0)
int main(void)
{
cmc_log_config.tlevel = CMC_LOG_TRACE;
struct cmc_timer timer;
cmc_timer_start(timer);
uintmax_t tests = 0, units = 0;
cmc_run(CMC_(CMC, TEST), units, tests);
cmc_run(CMC_(CMC, CMC_(TEST, Iter)), units, tests);
printf(" +---------------------------------------------------------------+\n");
printf(" | SUMMARY |\n");
printf(" +---------------------------------------------------------------+\n");
printf(" | Total Units Failed : %25" PRIuMAX " units |\n", units);
printf(" | Total Tests Failed : %25" PRIuMAX " tests |\n", tests);
printf(" | Total Asserts Failed : %25" PRIuMAX " asserts |\n", cmc_assert_failed);
printf(" | Total Runtime : %25.0lf milliseconds |\n", timer.result);
printf(" +---------------------------------------------------------------+\n");
return tests;
}