source: src/tests/minmax.c @ 026a0f5

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 026a0f5 was 3dcd347a, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

moved some more tests to new test folder

  • Property mode set to 100644
File size: 2.3 KB
RevLine 
[86bd7c1f]1//
2// Cforall Version 1.0.0 Copyright (C) 2015 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//
[5721a6d]7// minmax.c --
[86bd7c1f]8//
9// Author           : Richard C. Bilson
10// Created On       : Wed May 27 17:56:53 2015
11// Last Modified By : Peter A. Buhr
[90c3b1c]12// Last Modified On : Mon Feb 29 23:45:16 2016
13// Update Count     : 49
[86bd7c1f]14//
15
[d3b7937]16#include <fstream>
[bd85400]17#include <stdlib>                                                                               // min, max
[a0d9f94]18
[784deab]19int main( void ) {
[d3b7937]20        // char does not have less or greater than.
[784deab]21        int ?<?( char op1, char op2 ) { return (int)op1 < (int)op2; }
[d3b7937]22        int ?>?( char op1, char op2 ) { return (int)op1 > (int)op2; }
[784deab]23
24        sout | "char\t\t\t"                                     | 'z' | ' ' | 'a' | "\tmin " | min( 'z', 'a' ) | endl;
[90c3b1c]25        sout | "signed int\t\t"                         | 4 | 3 | "\tmin" | min( 4, 3 ) | endl;
26        sout | "unsigned int\t\t"                       | 4u | 3u | "\tmin" | min( 4u, 3u ) | endl;
27        sout | "signed long int\t\t"            | 4l | 3l | "\tmin" | min( 4l, 3l ) | endl;
28        sout | "unsigned long int\t"            | 4ul | 3ul | "\tmin" | min( 4ul, 3ul ) | endl;
29        sout | "signed long long int\t"         | 4ll | 3ll | "\tmin" | min( 4ll, 3ll ) | endl;
30        sout | "unsigned long long int\t"       | 4ull | 3ull | "\tmin" | min( 4ull, 3ull ) | endl;
31        sout | "float\t\t\t"                            | 4.0f | 3.1f | "\tmin" | min( 4.0f, 3.1f ) | endl;
32        sout | "double\t\t\t"                           | 4.0 | 3.1 | "\tmin" | min( 4.0, 3.1 ) | endl;
33        sout | "long double\t\t"                        | 4.0l | 3.1l | "\tmin" | min( 4.0l, 3.1l ) | endl;
[5721a6d]34
[d3b7937]35        sout | endl;
[5721a6d]36
[d3b7937]37        sout | "char\t\t\t"                                     | 'z' | ' ' | 'a' | "\tmax " | max( 'z', 'a' ) | endl;
[90c3b1c]38        sout | "signed int\t\t"                         | 4 | 3 | "\tmax" | max( 4, 3 ) | endl;
39        sout | "unsigned int\t\t"                       | 4u | 3u | "\tmax" | max( 4u, 3u ) | endl;
40        sout | "signed long int\t\t"            | 4l | 3l | "\tmax" | max( 4l, 3l ) | endl;
41        sout | "unsigned long int\t"            | 4ul | 3ul | "\tmax" | max( 4ul, 3ul ) | endl;
42        sout | "signed long long int\t"         | 4ll | 3ll | "\tmax" | max( 4ll, 3ll ) | endl;
43        sout | "unsigned long long int\t"       | 4ull | 3ull | "\tmax" | max( 4ull, 3ull ) | endl;
44        sout | "float\t\t\t"                            | 4.0f | 3.1f | "\tmax" | max( 4.0f, 3.1f ) | endl;
45        sout | "double\t\t\t"                           | 4.0 | 3.1 | "\tmax" | max( 4.0, 3.1 ) | endl;
46        sout | "long double\t\t"                        | 4.0l | 3.1l | "\tmax" | max( 4.0l, 3.1l ) | endl;
[784deab]47} // main
[42dcae7]48
49// Local Variables: //
[86bd7c1f]50// tab-width: 4 //
[d3b7937]51// compile-command: "cfa minmax.c" //
[42dcae7]52// End: //
Note: See TracBrowser for help on using the repository browser.