Changeset bf5a70da


Ignore:
Timestamp:
May 18, 2016, 12:36:20 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
85951a6
Parents:
f1e42c1
Message:

implemented simple link list test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/examples/gc_no_raii/test/badlll.c

    rf1e42c1 rbf5a70da  
    1515        int i;
    1616        LLL ll0, lll, llc;
    17         ctor(&ll0);
    18         ctor(&lll);
    19         ctor(&llc);
    2017
    2118        ll0 = gcmalloc();
     
    2320        lll = ll0;
    2421
     22        for (i = 1; i < sz; i++)
     23        {
     24                llc = gcnew<List_t>();
     25                llc->val = i;
     26                lll->next = llc;
     27                lll = llc;
     28        }
     29
    2530        return ll0;
    2631}
     32
     33void testLLL(LLL lll)
     34{
     35        unsigned char *counted;
     36
     37        counted = (unsigned char *) calloc(MAX, sizeof(unsigned char));
     38        while (lll)
     39        {
     40                counted[lll->val]++;
     41                if (counted[lll->val] > 1)
     42                {
     43                        fprintf(stderr, "ERROR! Encountered %d twice!\n", lll->val);
     44                        exit(1);
     45                }
     46                lll = lll->next;
     47        }
     48
     49        return;
     50}
     51
     52int main(void)
     53{
     54        LLL mylll;
     55
     56        mylll = buildLLL(MAX);
     57
     58        testLLL(mylll);
     59
     60        return 0;
     61}
Note: See TracChangeset for help on using the changeset viewer.