Lumiera  0.pre.03
»edit your freedom«
test-errorstate.c
Go to the documentation of this file.
1 /*
2  TEST-ERRORSTATE - test handling of error flags
3 
4  Copyright (C) Lumiera.org
5  2008, Christian Thaeter <ct@pipapo.org>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
30 #include <stdio.h>
31 #include <string.h>
32 
33 #include "lib/error.h"
34 
35 
36 LUMIERA_ERROR_DEFINE(TEST, "test error");
37 
38 int
39 main (int argc, char** argv)
40 {
41  if (argc == 1)
42  return 0;
43 
44  if (!strcmp(argv[1], "set"))
45  {
46  lumiera_error_set (LUMIERA_ERROR_TEST, NULL);
47  }
48 
49  if (!strcmp(argv[1], "get_no"))
50  {
51  const char* err;
52  err = lumiera_error ();
53  printf ("%p\n", err);
54  }
55 
56  if (!strcmp(argv[1], "get"))
57  {
58  lumiera_error_set (LUMIERA_ERROR_TEST, NULL);
59  const char* err;
60  err = lumiera_error ();
61  printf ("%s\n", err);
62  }
63 
64  if (!strcmp(argv[1], "get2"))
65  {
66  lumiera_error_set (LUMIERA_ERROR_TEST, NULL);
67  const char* err;
68  err = lumiera_error ();
69  printf ("%s\n", err);
70  err = lumiera_error ();
71  printf ("%p\n", err);
72  }
73 
74  return 0;
75 }
int main(int argc, const char *argv[])
run all tests or any single test specified in the first command line argument.
Definition: testrunner.cpp:47
Lumiera error handling (C interface).
lumiera_err lumiera_error(void)
Get and clear current error state.
Definition: error-state.c:124
lumiera_err lumiera_error_set(lumiera_err nerr, const char *extra)
Set error state for the current thread.
Definition: error-state.c:105
#define LUMIERA_ERROR_DEFINE(err, msg)
Definition and initialisation of an error constant.
Definition: error.h:80