summaryrefslogtreecommitdiff
path: root/libnautilus-extensions/nautilus-self-checks.h
blob: 73ff7e5c33a38edbed4f1ba9bc0fb645f0293194 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
   
   nautilus-self-checks.h: The self-check framework.
 
   Copyright (C) 1999 Eazel, Inc.
  
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.
  
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.
  
   You should have received a copy of the GNU General Public
   License along with this program; if not, write to the
   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
  
   Author: Darin Adler <darin@eazel.com>
*/

#ifndef NAUTILUS_SELF_CHECKS_H
#define NAUTILUS_SELF_CHECKS_H

#include <glib.h>
#include <libnautilus-extensions/nautilus-art-extensions.h>

#define NAUTILUS_CHECK_RESULT(type, expression, expected_value) \
G_STMT_START { \
	nautilus_before_check (#expression, __FILE__, __LINE__); \
	nautilus_check_##type##_result (expression, expected_value); \
} G_STMT_END

#define NAUTILUS_CHECK_BOOLEAN_RESULT(expression, expected_value) \
	NAUTILUS_CHECK_RESULT(boolean, expression, expected_value)
#define NAUTILUS_CHECK_INTEGER_RESULT(expression, expected_value) \
	NAUTILUS_CHECK_RESULT(integer, expression, expected_value)
#define NAUTILUS_CHECK_STRING_RESULT(expression, expected_value) \
	NAUTILUS_CHECK_RESULT(string, expression, expected_value)
#define NAUTILUS_CHECK_RECTANGLE_RESULT(expression, expected_x0, expected_y0, expected_x1, expected_y1) \
G_STMT_START { \
	nautilus_before_check (#expression, __FILE__, __LINE__); \
	nautilus_check_rectangle_result (expression, expected_x0, expected_y0, expected_x1, expected_y1); \
} G_STMT_END
#define NAUTILUS_CHECK_DIMENSIONS_RESULT(expression, expected_width, expected_height) \
G_STMT_START { \
	nautilus_before_check (#expression, __FILE__, __LINE__); \
	nautilus_check_dimensions_result (expression, expected_width, expected_height); \
} G_STMT_END

void nautilus_exit_if_self_checks_failed (void);
void nautilus_before_check_function      (const char         *name);
void nautilus_after_check_function       (void);
void nautilus_before_check               (const char         *expression,
					  const char         *file_name,
					  int                 line_number);
void nautilus_check_boolean_result       (gboolean            result,
					  gboolean            expected_value);
void nautilus_check_integer_result       (long                result,
					  long                expected_value);
void nautilus_check_rectangle_result     (ArtIRect            result,
					  int                 expected_x0,
					  int                 expected_y0,
					  int                 expected_x1,
					  int                 expected_y1);
void nautilus_check_dimensions_result    (NautilusDimensions  result,
					  int                 expected_width,
					  int                 expected_height);
void nautilus_check_string_result        (char               *result,
					  const char         *expected_value);

#define NAUTILUS_SELF_CHECK_FUNCTION_PROTOTYPE(function) \
	void function (void);

#define NAUTILUS_CALL_SELF_CHECK_FUNCTION(function) \
	nautilus_before_check_function (#function); \
	function (); \
	nautilus_after_check_function ();

#endif /* NAUTILUS_SELF_CHECKS_H */