1 /*
2 * FIG : Facility for Interactive Generation of figures
3 * Copyright (c) 1985-1988 by Supoj Sutanthavibul
4 * Parts Copyright (c) 1989-2015 by Brian V. Smith
5 * Parts Copyright (c) 1991 by Paul King
6 * Parts Copyright (c) 2016-2021 by Thomas Loimer
7 *
8 * Any party obtaining a copy of these files is granted, free of charge, a
9 * full and unrestricted irrevocable, world-wide, paid up, royalty-free,
10 * nonexclusive right and license to deal in this software and documentation
11 * files (the "Software"), including without limitation the rights to use,
12 * copy, modify, merge, publish, distribute, sublicense and/or sell copies of
13 * the Software, and to permit persons who receive copies from any such
14 * party to do so, with the only requirement being that the above copyright
15 * and this permission notice remain intact.
16 *
17 */
18
19 /*
20 * test1.c: Test {floor,ceil}_coords_[xy](), defined in src/u_bound.c.
21 * Author: Thomas Loimer, 2017-12-26
22 *
23 * Test, whether the "smaller than zero inverts problem"-lines in the
24 * {floor,ceil}_coords_[xy]() functions do not cause overflow.
25 */
26
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30
31 #include <limits.h>
32
33 extern int floor_coords_x(); /* from "u_bound.h" */
34 extern int floor_coords_y(); /* from "u_bound.h" */
35 extern int ceil_coords_x(); /* from "u_bound.h" */
36 extern int ceil_coords_y(); /* from "u_bound.h" */
37 extern int cur_pointposn; /* mode.h */
38
39 /* stubs */
40 void
round_coords(int * x,int * y)41 round_coords(int *x, int *y)
42 {
43 (void) x; (void) y;
44 }
45
46 int
main(void)47 main(void)
48 {
49 int errcode = 0;
50
51 cur_pointposn = 2; /* == P_GRID1, see mode.h */
52
53 /* Since round_coords() is replaced by the no-op above, the
54 expected results are as below. */
55 if (floor_coords_x(INT_MIN, 0) != INT_MIN)
56 errcode |= 0x1;
57 if (floor_coords_y(0, INT_MIN) != INT_MIN)
58 errcode |= 0x2;
59 if (ceil_coords_x(INT_MIN, 0) != -INT_MAX)
60 errcode |= 0x4;
61 if (ceil_coords_y(0, INT_MIN) != -INT_MAX)
62 errcode |= 0x8;
63 return errcode;
64 }
65