Added include guards to test src and formatting tests
This commit is contained in:
1 parent
e4a7b01d3a
commit
7340866da1
33 files changed
+157
-1081
No files matched your search
+8
-1
@@ -86,7 +86,14 @@ for data in collections:
|
||||
|
||||
file = open(f'{OUTPUT_DIR}/{data["sname"]}.c', 'w')
|
||||
|
||||
file.write(f'#include {data["h"]}\n{match.group("code")}')
|
||||
file.write(
|
||||
f'''#ifndef CMC_TEST_SRC_{data['t']}
|
||||
#define CMC_TEST_SRC_{data['t']}
|
||||
|
||||
#include {data["h"]}\n{match.group("code")}
|
||||
|
||||
#endif /* CMC_TEST_SRC_{data['t']} */
|
||||
''')
|
||||
|
||||
file.flush()
|
||||
file.close()
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef CMC_TEST_SRC_BITSET
|
||||
#define CMC_TEST_SRC_BITSET
|
||||
|
||||
#include "cmc/bitset.h"
|
||||
|
||||
struct bitset
|
||||
@@ -331,3 +334,5 @@ _Bool bs_impl_resize(struct bitset *_bitset_, size_t n_bits, _Bool do_resize)
|
||||
_bitset_->flag = cmc_flags.OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* CMC_TEST_SRC_BITSET */
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef CMC_TEST_SRC_DEQUE
|
||||
#define CMC_TEST_SRC_DEQUE
|
||||
|
||||
#include "cmc/deque.h"
|
||||
|
||||
struct deque
|
||||
@@ -565,3 +568,5 @@ size_t d_iter_index(struct deque_iter *iter)
|
||||
{
|
||||
return iter->index;
|
||||
}
|
||||
|
||||
#endif /* CMC_TEST_SRC_DEQUE */
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef CMC_TEST_SRC_HASHBIDIMAP
|
||||
#define CMC_TEST_SRC_HASHBIDIMAP
|
||||
|
||||
#include "cmc/hashbidimap.h"
|
||||
|
||||
struct hashbidimap
|
||||
@@ -973,3 +976,5 @@ static struct hashbidimap_iter hbm_impl_it_end(struct hashbidimap *_map_)
|
||||
hbm_iter_to_end(&iter);
|
||||
return iter;
|
||||
}
|
||||
|
||||
#endif /* CMC_TEST_SRC_HASHBIDIMAP */
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef CMC_TEST_SRC_HASHMAP
|
||||
#define CMC_TEST_SRC_HASHMAP
|
||||
|
||||
#include "cmc/hashmap.h"
|
||||
|
||||
struct hashmap
|
||||
@@ -842,3 +845,5 @@ static size_t hm_impl_calculate_size(size_t required)
|
||||
i++;
|
||||
return cmc_hashtable_primes[i];
|
||||
}
|
||||
|
||||
#endif /* CMC_TEST_SRC_HASHMAP */
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef CMC_TEST_SRC_HASHMULTIMAP
|
||||
#define CMC_TEST_SRC_HASHMULTIMAP
|
||||
|
||||
#include "cmc/hashmultimap.h"
|
||||
|
||||
struct hashmultimap
|
||||
@@ -1009,3 +1012,5 @@ size_t hmm_impl_calculate_size(size_t required)
|
||||
i++;
|
||||
return cmc_hashtable_primes[i];
|
||||
}
|
||||
|
||||
#endif /* CMC_TEST_SRC_HASHMULTIMAP */
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef CMC_TEST_SRC_HASHMULTISET
|
||||
#define CMC_TEST_SRC_HASHMULTISET
|
||||
|
||||
#include "cmc/hashmultiset.h"
|
||||
|
||||
struct hashmultiset
|
||||
@@ -1056,3 +1059,5 @@ static size_t hms_impl_calculate_size(size_t required)
|
||||
i++;
|
||||
return cmc_hashtable_primes[i];
|
||||
}
|
||||
|
||||
#endif /* CMC_TEST_SRC_HASHMULTISET */
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef CMC_TEST_SRC_HASHSET
|
||||
#define CMC_TEST_SRC_HASHSET
|
||||
|
||||
#include "cmc/hashset.h"
|
||||
|
||||
struct hashset
|
||||
@@ -848,3 +851,5 @@ static size_t hs_impl_calculate_size(size_t required)
|
||||
i++;
|
||||
return cmc_hashtable_primes[i];
|
||||
}
|
||||
|
||||
#endif /* CMC_TEST_SRC_HASHSET */
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef CMC_TEST_SRC_HEAP
|
||||
#define CMC_TEST_SRC_HEAP
|
||||
|
||||
#include "cmc/heap.h"
|
||||
|
||||
struct heap
|
||||
@@ -491,3 +494,5 @@ static void h_impl_float_down(struct heap *_heap_, size_t index)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CMC_TEST_SRC_HEAP */
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef CMC_TEST_SRC_INTERVALHEAP
|
||||
#define CMC_TEST_SRC_INTERVALHEAP
|
||||
|
||||
#include "cmc/intervalheap.h"
|
||||
|
||||
struct intervalheap
|
||||
@@ -756,3 +759,5 @@ static void ih_impl_float_down_min(struct intervalheap *_heap_)
|
||||
curr_node = child_node;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CMC_TEST_SRC_INTERVALHEAP */
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef CMC_TEST_SRC_LINKEDLIST
|
||||
#define CMC_TEST_SRC_LINKEDLIST
|
||||
|
||||
#include "cmc/linkedlist.h"
|
||||
|
||||
struct linkedlist
|
||||
@@ -760,3 +763,5 @@ struct linkedlist_node *ll_iter_node(struct linkedlist_iter *iter)
|
||||
{
|
||||
return iter->cursor;
|
||||
}
|
||||
|
||||
#endif /* CMC_TEST_SRC_LINKEDLIST */
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef CMC_TEST_SRC_LIST
|
||||
#define CMC_TEST_SRC_LIST
|
||||
|
||||
#include "cmc/list.h"
|
||||
|
||||
struct list
|
||||
@@ -713,3 +716,5 @@ size_t l_iter_index(struct list_iter *iter)
|
||||
{
|
||||
return iter->cursor;
|
||||
}
|
||||
|
||||
#endif /* CMC_TEST_SRC_LIST */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,3 +1,6 @@
|
||||
#ifndef CMC_TEST_SRC_QUEUE
|
||||
#define CMC_TEST_SRC_QUEUE
|
||||
|
||||
#include "cmc/queue.h"
|
||||
|
||||
struct queue
|
||||
@@ -494,3 +497,5 @@ size_t q_iter_index(struct queue_iter *iter)
|
||||
{
|
||||
return iter->index;
|
||||
}
|
||||
|
||||
#endif /* CMC_TEST_SRC_QUEUE */
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef CMC_TEST_SRC_SORTEDLIST
|
||||
#define CMC_TEST_SRC_SORTEDLIST
|
||||
|
||||
#include "cmc/sortedlist.h"
|
||||
|
||||
struct sortedlist
|
||||
@@ -584,3 +587,5 @@ void sl_impl_sort_insertion(size_t *array, int (*cmp)(size_t, size_t),
|
||||
array[j] = _tmp_;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CMC_TEST_SRC_SORTEDLIST */
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef CMC_TEST_SRC_STACK
|
||||
#define CMC_TEST_SRC_STACK
|
||||
|
||||
#include "cmc/stack.h"
|
||||
|
||||
struct stack
|
||||
@@ -428,3 +431,5 @@ size_t s_iter_index(struct stack_iter *iter)
|
||||
return 0;
|
||||
return iter->target->count - 1 - iter->cursor;
|
||||
}
|
||||
|
||||
#endif /* CMC_TEST_SRC_STACK */
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef CMC_TEST_SRC_TREEMAP
|
||||
#define CMC_TEST_SRC_TREEMAP
|
||||
|
||||
#include "cmc/treemap.h"
|
||||
|
||||
struct treemap
|
||||
@@ -883,3 +886,5 @@ static void tm_impl_rebalance(struct treemap *_map_, struct treemap_node *node)
|
||||
scan = scan->parent;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CMC_TEST_SRC_TREEMAP */
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef CMC_TEST_SRC_TREESET
|
||||
#define CMC_TEST_SRC_TREESET
|
||||
|
||||
#include "cmc/treeset.h"
|
||||
|
||||
struct treeset
|
||||
@@ -925,3 +928,5 @@ static void ts_impl_rebalance(struct treeset *_set_, struct treeset_node *node)
|
||||
scan = scan->parent;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CMC_TEST_SRC_TREESET */
|
||||
@@ -364,8 +364,7 @@ CMC_CREATE_UNIT(BitSet, true, {
|
||||
|
||||
cmc_assert(bs_put_range(bs, 0, word_bits * 100 - 1, false));
|
||||
for (size_t i = 0; i < bs->capacity; i++)
|
||||
cmc_assert_equals(CMC_BITSET_WORD_TYPE, 0,
|
||||
bs->buffer[i]);
|
||||
cmc_assert_equals(CMC_BITSET_WORD_TYPE, 0, bs->buffer[i]);
|
||||
|
||||
bs_free(bs);
|
||||
});
|
||||
|
||||
@@ -1732,10 +1732,12 @@ int main(void)
|
||||
{
|
||||
int result = Deque() + DequeIter();
|
||||
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n");
|
||||
printf(" | Deque Suit : %-48s |\n", result == 0 ? "PASSED" : "FAILED");
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n\n\n");
|
||||
|
||||
return result;
|
||||
|
||||
@@ -825,19 +825,23 @@ CMC_CREATE_UNIT(HashBidiMap, true, {
|
||||
});
|
||||
});
|
||||
|
||||
CMC_CREATE_UNIT(HashBidiMapIter, true, {
|
||||
CMC_CREATE_UNIT(HashBidiMapIter, true,
|
||||
{
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
#ifdef CMC_TEST_MAIN
|
||||
int main(void)
|
||||
{
|
||||
int result = HashBidiMap() + HashBidiMapIter();
|
||||
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n");
|
||||
printf(" | HashBidiMap Suit : %-42s |\n", result == 0 ? "PASSED" : "FAILED");
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(" | HashBidiMap Suit : %-42s |\n",
|
||||
result == 0 ? "PASSED" : "FAILED");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n\n\n");
|
||||
|
||||
return result;
|
||||
|
||||
@@ -1344,10 +1344,12 @@ int main(void)
|
||||
{
|
||||
int result = HashMap() + HashMapIter();
|
||||
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n");
|
||||
printf(" | HashMap Suit : %-46s |\n", result == 0 ? "PASSED" : "FAILED");
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n\n\n");
|
||||
|
||||
return result;
|
||||
|
||||
@@ -944,10 +944,13 @@ int main(void)
|
||||
{
|
||||
int result = HashMultiMap() + HashMultiMapIter();
|
||||
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n");
|
||||
printf(" | HashMultiMap Suit : %-41s |\n", result == 0 ? "PASSED" : "FAILED");
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(" | HashMultiMap Suit : %-41s |\n",
|
||||
result == 0 ? "PASSED" : "FAILED");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n\n\n");
|
||||
|
||||
return result;
|
||||
|
||||
@@ -864,10 +864,13 @@ int main(void)
|
||||
{
|
||||
int result = HashMultiSet() + HashMultiSetIter();
|
||||
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n");
|
||||
printf(" | HashMultiSet Suit : %-41s |\n", result == 0 ? "PASSED" : "FAILED");
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(" | HashMultiSet Suit : %-41s |\n",
|
||||
result == 0 ? "PASSED" : "FAILED");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n\n\n");
|
||||
|
||||
return result;
|
||||
|
||||
@@ -1042,10 +1042,12 @@ int main(void)
|
||||
{
|
||||
int result = HashSet() + HashSetIter();
|
||||
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n");
|
||||
printf(" | HashSet Suit : %-46s |\n", result == 0 ? "PASSED" : "FAILED");
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n\n\n");
|
||||
|
||||
return result;
|
||||
|
||||
@@ -1044,10 +1044,13 @@ int main(void)
|
||||
{
|
||||
int result = IntervalHeap() + IntervalHeapIter();
|
||||
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n");
|
||||
printf(" | IntervalHeap Suit : %-41s |\n", result == 0 ? "PASSED" : "FAILED");
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(" | IntervalHeap Suit : %-41s |\n",
|
||||
result == 0 ? "PASSED" : "FAILED");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n\n\n");
|
||||
|
||||
return result;
|
||||
|
||||
@@ -804,10 +804,12 @@ int main(void)
|
||||
{
|
||||
int result = LinkedList() + LinkedListIter();
|
||||
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n");
|
||||
printf(" | LinkedList Suit : %-43s |\n", result == 0 ? "PASSED" : "FAILED");
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n\n\n");
|
||||
|
||||
return result;
|
||||
|
||||
@@ -1070,10 +1070,12 @@ int main(void)
|
||||
{
|
||||
int result = List() + ListIter();
|
||||
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n");
|
||||
printf(" | List Suit : %-49s |\n", result == 0 ? "PASSED" : "FAILED");
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n\n\n");
|
||||
|
||||
return result;
|
||||
|
||||
@@ -688,7 +688,7 @@ CMC_CREATE_UNIT(QueueIter, true, {
|
||||
cmc_assert(!q_iter_to_end(&it));
|
||||
|
||||
for (size_t i = 1; i <= 100; i++)
|
||||
q_enqueue(q, i);
|
||||
q_enqueue(q, i);
|
||||
|
||||
it = q_iter_start(q);
|
||||
|
||||
@@ -960,10 +960,12 @@ int main(void)
|
||||
{
|
||||
int result = Queue() + QueueIter();
|
||||
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n");
|
||||
printf(" | Queue Suit : %-48s |\n", result == 0 ? "PASSED" : "FAILED");
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n\n\n");
|
||||
|
||||
return result;
|
||||
|
||||
@@ -705,10 +705,12 @@ int main(void)
|
||||
{
|
||||
int result = SortedList() + SortedListIter();
|
||||
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n");
|
||||
printf(" | SortedList Suit : %-43s |\n", result == 0 ? "PASSED" : "FAILED");
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n\n\n");
|
||||
|
||||
return result;
|
||||
|
||||
@@ -838,10 +838,12 @@ int main(void)
|
||||
{
|
||||
int result = Stack() + StackIter();
|
||||
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n");
|
||||
printf(" | Stack Suit : %-48s |\n", result == 0 ? "PASSED" : "FAILED");
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n\n\n");
|
||||
|
||||
return result;
|
||||
|
||||
@@ -659,10 +659,12 @@ int main(void)
|
||||
{
|
||||
int result = TreeMap() + TreeMapIter();
|
||||
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n");
|
||||
printf(" | TreeMap Suit : %-46s |\n", result == 0 ? "PASSED" : "FAILED");
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n\n\n");
|
||||
|
||||
return result;
|
||||
|
||||
@@ -574,10 +574,12 @@ int main(void)
|
||||
{
|
||||
int result = TreeSet() + TreeSetIter();
|
||||
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n");
|
||||
printf(" | TreeSet Suit : %-46s |\n", result == 0 ? "PASSED" : "FAILED");
|
||||
printf(" +---------------------------------------------------------------+");
|
||||
printf(
|
||||
" +---------------------------------------------------------------+");
|
||||
printf("\n\n\n");
|
||||
|
||||
return result;
|
||||
|
||||
Reference in new issue
Block a user