source: src/tests/random.c@ efd6e4a5

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since efd6e4a5 was adcc065, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

add labelled break to if statement, update comment formatting, add random number test

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[ed0e67a]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.c --
8//
9// Author : Peter A. Buhr
10// Created On : Tue Jul 5 21:29:30 2016
11// Last Modified By : Peter A. Buhr
[adcc065]12// Last Modified On : Wed Jul 6 18:00:29 2016
13// Update Count : 3
[ed0e67a]14//
[5721a6d]15
16#include <fstream>
[bd85400]17#include <stdlib> // random
[ed0e67a]18#include <unistd.h> // getpid
[5721a6d]19
20int main() {
[adcc065]21 //rand48seed( getpid() ); // set random seed
22 rand48seed( 1003 ); // fixed seed for repeatable tests
[5721a6d]23
24 // test polymorphic calls to random and stream
[0438091]25 char c = rand48();
[5721a6d]26 sout | c | endl;
[0438091]27 int i = rand48();
[5721a6d]28 sout | i | endl;
[0438091]29 unsigned int ui = rand48();
[5721a6d]30 sout | ui | endl;
[0438091]31 long int li = rand48();
[5721a6d]32 sout | li | endl;
[0438091]33 unsigned long int uli = rand48();
[5721a6d]34 sout | uli | endl;
[0438091]35 float f = rand48();
[5721a6d]36 sout | f | endl;
[0438091]37 double d = rand48();
[5721a6d]38 sout | d | endl;
[0438091]39 float _Complex fc = rand48();
[5721a6d]40 sout | fc | endl;
[0438091]41 double _Complex dc = rand48();
[5721a6d]42 sout | dc | endl;
[0438091]43 long double _Complex ldc = rand48();
[5721a6d]44 sout | ldc | endl;
45} // main
46
47// Local Variables: //
48// tab-width: 4 //
49// compile-command: "cfa random.c" //
50// End: //
Note: See TracBrowser for help on using the repository browser.