source: tests/random.cfa @ 4ff7ea3

Last change on this file since 4ff7ea3 was 200fcb3, checked in by Peter A. Buhr <pabuhr@…>, 6 years ago

add auto newline to sout, change endl to nl

  • Property mode set to 100644
File size: 1.6 KB
Line 
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// random.cfa --
8//
9// Author           : Peter A. Buhr
10// Created On       : Tue Jul  5 21:29:30 2016
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Tue Dec  4 21:46:25 2018
13// Update Count     : 22
14//
15
16#include <fstream.hfa>
17#include <stdlib.hfa>                                                                   // random
18#include <unistd.h>                                                                             // getpid
19
20int main() {
21        // srandom( getpid() );                                                         // set random seed
22        srandom( 1003 );                                                                        // fixed seed for repeatable tests
23
24        // test polymorphic calls to random and stream
25        char c = random();
26        sout | c;
27        c = random( 'A' );
28        sout | c;
29        c = random( 'A', 'Z' );
30        sout | c;
31
32        int i = random();
33    sout | i;
34        i = random( 10 );
35    sout | i;
36        i = random( -10, 20 );
37    sout | i;
38
39        unsigned int ui = random();
40    sout | ui;
41        ui = random( 10u );
42    sout | ui;
43        ui = random( 10u, 20u );
44    sout | ui;
45
46        long int li = random();
47    sout | li;
48        li = random( 10l );
49    sout | li;
50        li = random( -10l, 20l );
51    sout | li;
52
53        unsigned long int uli = random();
54    sout | uli;
55        uli = random( 10ul );
56    sout | uli;
57        uli = random( 10ul, 20ul );
58    sout | uli;
59
60    float f = random();
61    sout | f;
62
63    double d = random();
64    sout | d;
65
66    float _Complex fc = random();
67    sout | fc;
68
69    double _Complex dc = random();
70    sout | dc;
71
72    long double _Complex ldc = random();
73    sout | ldc;
74} // main
75
76// Local Variables: //
77// tab-width: 4 //
78// compile-command: "cfa random.cfa" //
79// End: //
Note: See TracBrowser for help on using the repository browser.