Mercurial > hg > octave-lojdl > gnulib-hg
annotate tests/test-verify.c @ 7376:5b76a3b030e7
.
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Wed, 27 Sep 2006 07:37:50 +0000 |
parents | 0ec466622052 |
children | 633babea5f62 |
rev | line source |
---|---|
7134
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
1 /* Test the "verify" module. |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
2 |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
3 Copyright (C) 2005 Free Software Foundation, Inc. |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
4 |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
5 This program is free software; you can redistribute it and/or modify |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
6 it under the terms of the GNU General Public License as published by |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
7 the Free Software Foundation; either version 2, or (at your option) |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
8 any later version. |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
9 |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
10 This program is distributed in the hope that it will be useful, |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
13 GNU General Public License for more details. |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
14 |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
15 You should have received a copy of the GNU General Public License |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
16 along with this program; if not, write to the Free Software Foundation, |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
18 |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
19 /* Written by Bruno Haible. */ |
0ec466622052
* check-module: Add copyright notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6313
diff
changeset
|
20 |
6287
3ab48f830628
Include config.h only if it exists.
Bruno Haible <bruno@clisp.org>
parents:
6277
diff
changeset
|
21 #ifdef HAVE_CONFIG_H |
3ab48f830628
Include config.h only if it exists.
Bruno Haible <bruno@clisp.org>
parents:
6277
diff
changeset
|
22 # include <config.h> |
3ab48f830628
Include config.h only if it exists.
Bruno Haible <bruno@clisp.org>
parents:
6277
diff
changeset
|
23 #endif |
3ab48f830628
Include config.h only if it exists.
Bruno Haible <bruno@clisp.org>
parents:
6277
diff
changeset
|
24 |
6276 | 25 #include "verify.h" |
26 | |
27 int x; | |
28 enum { a, b, c }; | |
29 | |
30 verify (x >= 0); /* should give ERROR: non-constant expression */ | |
31 verify (c == 2); /* should be ok */ | |
32 verify (1 + 1 == 3); /* should give ERROR */ | |
33 verify (1 == 1); verify (1 == 1); /* should be ok */ | |
34 | |
6313
f07684ccd866
Test verify_true instead of verify_expr.
Bruno Haible <bruno@clisp.org>
parents:
6287
diff
changeset
|
35 enum |
f07684ccd866
Test verify_true instead of verify_expr.
Bruno Haible <bruno@clisp.org>
parents:
6287
diff
changeset
|
36 { |
f07684ccd866
Test verify_true instead of verify_expr.
Bruno Haible <bruno@clisp.org>
parents:
6287
diff
changeset
|
37 item = verify_true (1 == 1) * 0 + 17 /* should be ok */ |
f07684ccd866
Test verify_true instead of verify_expr.
Bruno Haible <bruno@clisp.org>
parents:
6287
diff
changeset
|
38 }; |
f07684ccd866
Test verify_true instead of verify_expr.
Bruno Haible <bruno@clisp.org>
parents:
6287
diff
changeset
|
39 |
6276 | 40 int function (int n) |
41 { | |
42 verify (n >= 0); /* should give ERROR: non-constant expression */ | |
43 verify (c == 2); /* should be ok */ | |
44 verify (1 + 1 == 3); /* should give ERROR */ | |
45 verify (1 == 1); verify (1 == 1); /* should be ok */ | |
46 | |
47 if (n) | |
6313
f07684ccd866
Test verify_true instead of verify_expr.
Bruno Haible <bruno@clisp.org>
parents:
6287
diff
changeset
|
48 return (verify_true (1 == 1), verify_true (1 == 1), 7); /* should be ok */ |
6276 | 49 else |
6313
f07684ccd866
Test verify_true instead of verify_expr.
Bruno Haible <bruno@clisp.org>
parents:
6287
diff
changeset
|
50 return (verify_true (1 == 2), 5); /* should give ERROR */ |
6276 | 51 } |