Commit | Line | Data |
---|---|---|
1479465f GJ |
1 | /* |
2 | * libdpkg - Debian packaging suite library routines | |
3 | * t-macros.c - test C support macros | |
4 | * | |
5 | * Copyright © 2009,2012 Guillem Jover <guillem@debian.org> | |
6 | * | |
7 | * This is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This 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, see <https://www.gnu.org/licenses/>. | |
19 | */ | |
20 | ||
21 | #include <config.h> | |
22 | #include <compat.h> | |
23 | ||
24 | #include <dpkg/test.h> | |
25 | #include <dpkg/macros.h> | |
26 | ||
27 | TEST_ENTRY(test) | |
28 | { | |
29 | test_plan(12); | |
30 | ||
31 | test_pass(min(10, 30) == 10); | |
32 | test_pass(min(30, 10) == 10); | |
33 | test_pass(min(0, 10) == 0); | |
34 | test_pass(min(-10, 0) == -10); | |
35 | ||
36 | test_pass(max(10, 30) == 30); | |
37 | test_pass(max(30, 10) == 30); | |
38 | test_pass(max(0, 10) == 10); | |
39 | test_pass(max(-10, 0) == 0); | |
40 | ||
41 | test_pass(clamp(0, 0, 0) == 0); | |
42 | test_pass(clamp(0, -10, 10) == 0); | |
43 | test_pass(clamp(20, -10, 10) == 10); | |
44 | test_pass(clamp(-20, -10, 10) == -10); | |
45 | } |