ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since 62315a0 was
dc8511c,
checked in by Peter A. Buhr <pabuhr@…>, 6 years ago
|
first attempt at updating suffixes for test programs
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[20877d2] | 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 | // |
---|
| 7 | // maybe.c -- |
---|
| 8 | // |
---|
| 9 | // Author : Andrew Beach |
---|
| 10 | // Created On : Thr May 25 16:02:00 2017 |
---|
[91c389a] | 11 | // Last Modified By : Peter A. Buhr |
---|
| 12 | // Last Modified On : Thu Jul 20 15:24:07 2017 |
---|
| 13 | // Update Count : 1 |
---|
[20877d2] | 14 | // |
---|
| 15 | |
---|
[91c389a] | 16 | #include <assert.h> |
---|
[58b6d1b] | 17 | #include <containers/maybe.hfa> |
---|
[20877d2] | 18 | |
---|
| 19 | void checkPredicates() { |
---|
| 20 | maybe(int) filled = 4; |
---|
| 21 | assert(filled); |
---|
| 22 | assert(has_value(&filled)); |
---|
| 23 | |
---|
| 24 | maybe(int) empty = {}; |
---|
| 25 | assert(empty ? false : true); |
---|
| 26 | assert(!has_value(&empty)); |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | void checkGetter() { |
---|
| 30 | maybe(int) a = 94; |
---|
| 31 | assert(94 == get(&a)); |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | /* Waiting on bug#11 to be fixed. |
---|
| 35 | void checkNamedConstructors() { |
---|
| 36 | maybe(char) letter = maybe_value('a'); |
---|
| 37 | assert(has_value(&letter)); |
---|
| 38 | assert('a' == get(&letter)); |
---|
| 39 | |
---|
| 40 | maybe(char) rune = maybe_none(); |
---|
| 41 | assert(!has_value(&rune)); |
---|
| 42 | } |
---|
| 43 | */ |
---|
| 44 | |
---|
| 45 | void checkSetters() { |
---|
| 46 | maybe(int) fee = 3; |
---|
| 47 | assert(3 == get(&fee)); |
---|
| 48 | set(&fee, 7); |
---|
| 49 | assert(7 == get(&fee)); |
---|
| 50 | set_none(&fee); |
---|
| 51 | assert(!has_value(&fee)); |
---|
| 52 | |
---|
| 53 | maybe(int) fy = 4; |
---|
| 54 | maybe(int) foe = 8; |
---|
| 55 | maybe(int) fum = {}; |
---|
| 56 | fy = foe; |
---|
| 57 | assert(8 == get(&fy)); |
---|
| 58 | fy = fum; |
---|
| 59 | assert(!has_value(&fy)); |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | int main(int argc, char * argv[]) { |
---|
| 63 | checkPredicates(); |
---|
| 64 | checkGetter(); |
---|
| 65 | //checkNamedConstructors(); |
---|
| 66 | checkSetters(); |
---|
| 67 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.