Changeset 00b7cd3


Ignore:
Timestamp:
Jul 5, 2016, 5:03:40 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
a922e34
Parents:
3a808fd
Message:

update include files for test programs

Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/containers/vector

    r3a808fd r00b7cd3  
    11#pragma once
    22
     3extern "C" {
    34#include <stdbool.h>
    4 #include <stdlib>
     5}
    56
    67#define DESTROY(x)
  • src/tests/ato.c

    r3a808fd r00b7cd3  
    1 //                               -*- Mode: C -*-
    21//
    32// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    1110// Created On       : Thu Feb  4 08:10:57 2016
    1211// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Mon Feb 29 17:57:35 2016
    14 // Update Count     : 44
     12// Last Modified On : Mon Jul  4 23:38:04 2016
     13// Update Count     : 48
    1514//
    1615
    1716#include <fstream>
    1817#include <stdlib>                                                                               // ato, strto
    19 extern "C" {
    20 #include <stdio.h>
    21 #include <float.h>
    22 }
    2318
    2419int main( void ) {
  • src/tests/avltree/avl.h

    r3a808fd r00b7cd3  
    66void free(void *);
    77#define assert(cond) if (! (cond)) { printf("Assertion failed: (%s) at %s:%d\n", #cond, __FILE__, __LINE__); abort(); }
    8 void abort();
    98int printf(const char *, ...);
    109}
  • src/tests/extension.c

    r3a808fd r00b7cd3  
    11//
    2 // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
     2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// extension.c --
     
    77// Created On       : Mon Jul  4 20:42:43 2016
    88// Last Modified By : Peter A. Buhr
    9 // Last Modified On : Mon Jul  4 20:43:51 2016
    10 // Update Count     : 2
     9// Last Modified On : Mon Jul  4 23:31:22 2016
     10// Update Count     : 3
    1111//
    1212
  • src/tests/init_once.c

    r3a808fd r00b7cd3  
    99// Author           : Rob Schluntz
    1010// Created On       : Tue Jun 14 15:43:35 2016
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Jun 14 15:45:03 2016
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Jul  5 16:40:07 2016
     13// Update Count     : 2
    1414//
    1515
     
    2828void free(void *);
    2929#define assert(cond) if (! (cond)) { printf("Assertion failed: (%s) at %s:%d\n", #cond, __FILE__, __LINE__); abort(); }
    30 void abort();
    3130int printf(const char *, ...);
    3231void *memset(void *s, int c, size_t n);
  • src/tests/libcfa_vector.c

    r3a808fd r00b7cd3  
    1 #include <stdlib>
     1//
     2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     3//
     4// The contents of this file are covered under the licence agreement in the
     5// file "LICENCE" distributed with Cforall.
     6//
     7// libcfa_vector.c --
     8//
     9// Author           : Thierry Delisle
     10// Created On       : Mon Jul  4 23:36:19 2016
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Jul  5 15:08:05 2016
     13// Update Count     : 26
     14//
    215
    3 extern "C" {
    4         #include <stdio.h>
     16#include <fstream>
     17#include <vector>
     18
     19#undef assert
     20#define assert(x)                                                               \
     21        do {                                                                            \
     22                if ( !(x) ) {                                                   \
     23                        sout | "CHECK failed :" | #x | "at" | __FILE__ | " :" | __LINE__ | endl;        \
     24                        abort();                                                        \
     25                }                                                                               \
     26        } while( 0 == 1 )
     27
     28int main() {
     29        vector( int, heap_allocator(int) ) iv;
     30        ctor( &iv );
     31
     32        assert( empty( &iv ) );
     33        assert( size( &iv ) == 0 );
     34        sout | size( &iv ) | endl;
     35
     36        push_back( &iv, 1 );
     37        assert( size( &iv ) == 1 );
     38        sout | size( &iv ) | endl;
     39
     40        push_back( &iv, 2 );
     41        assert( size( &iv ) == 2 );
     42        sout | size( &iv ) | endl;
     43
     44        push_back( &iv, 3 );
     45        assert( size( &iv ) == 3 );
     46        sout | size( &iv ) | endl;
     47
     48        assert( !empty( &iv ) );
     49        assert( size( &iv ) == 3 );
     50        assert( at( &iv, 0 ) == 1 );
     51        assert( (&iv)[0] == 1 );
     52        assert( at( &iv, 1 ) == 2 );
     53        assert( (&iv)[1] == 2 );
     54        assert( at( &iv, 2 ) == 3 );
     55        assert( (&iv)[2] == 3 );
     56
     57        clear( &iv );
     58
     59        assert( empty( &iv ) );
     60        assert( size( &iv ) == 0 );
     61        sout | size( &iv ) | endl;
    562}
    663
    7 #include <containers/vector>
    8 
    9 #define assert(x) do {\
    10         if(!(x)) {\
    11                 printf("CHECK failed : %s at %s:%i\n", #x, __FILE__, __LINE__);\
    12                 abort();\
    13         }}while(0 == 1)\
    14 
    15 int main(int argc, char const *argv[]) {
    16         vector(int, heap_allocator(int)) iv;
    17         ctor(&iv);
    18 
    19         assert(empty(&iv));
    20         assert(size(&iv) == 0);
    21         printf("%d\n", size(&iv));
    22 
    23         push_back(&iv, 1);
    24         printf("%d\n", size(&iv));
    25         assert(size(&iv) == 1);
    26         push_back(&iv, 2);
    27         printf("%d\n", size(&iv));
    28         assert(size(&iv) == 2);
    29         push_back(&iv, 3);
    30         printf("%d\n", size(&iv));
    31         assert(size(&iv) == 3);
    32 
    33         assert(!empty(&iv));
    34         assert(size(&iv) == 3);
    35         assert(at(&iv, 0) == 1);
    36         assert((&iv)[0] == 1);
    37         assert(at(&iv, 1) == 2);
    38         assert((&iv)[1] == 2);
    39         assert(at(&iv, 2) == 3);
    40         assert((&iv)[2] == 3);
    41 
    42         clear(&iv);
    43 
    44         assert(empty(&iv));
    45         assert(size(&iv) == 0);
    46         printf("%d\n", size(&iv));
    47 
    48         return 0;
    49 }
     64// Local Variables: //
     65// tab-width: 4 //
     66// compile-command: "cfa libcfa_vector.c" //
     67// End: //
Note: See TracChangeset for help on using the changeset viewer.