[hkl] add hkl_geometry_[sample/detector]_rotation_get
[hkl.git] / tests / hkl-unit-t.c
blobd7f33b5d4952e1cfe1aeb46e35e74abd78968a07
1 /* This file is part of the hkl library.
3 * The hkl library is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * The hkl library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with the hkl library. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright (C) 2003-2016 Synchrotron SOLEIL
17 * L'Orme des Merisiers Saint-Aubin
18 * BP 48 91192 GIF-sur-YVETTE CEDEX
20 * Authors: Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>
22 #include "hkl.h"
23 #include <tap/basic.h>
24 #include <tap/float.h>
25 #include <tap/hkl-tap.h>
27 #include "hkl-unit-private.h"
29 static void compatible(void)
31 int res = TRUE;
33 res &= DIAG(hkl_unit_compatible(&hkl_unit_angle_deg, &hkl_unit_angle_rad));
34 res &= DIAG(!hkl_unit_compatible(&hkl_unit_angle_deg, &hkl_unit_length_nm));
35 res &= DIAG(!hkl_unit_compatible(&hkl_unit_angle_rad, &hkl_unit_length_nm));
37 /* mrad */
38 res &= DIAG(hkl_unit_compatible(&hkl_unit_angle_mrad, &hkl_unit_angle_deg));
39 res &= DIAG(hkl_unit_compatible(&hkl_unit_angle_mrad, &hkl_unit_angle_rad));
40 res &= DIAG(hkl_unit_compatible(&hkl_unit_angle_deg, &hkl_unit_angle_mrad));
41 res &= DIAG(hkl_unit_compatible(&hkl_unit_angle_rad, &hkl_unit_angle_mrad));
42 res &= DIAG(!hkl_unit_compatible(&hkl_unit_angle_mrad, &hkl_unit_length_nm));
43 res &= DIAG(!hkl_unit_compatible(&hkl_unit_length_nm, &hkl_unit_angle_mrad));
45 res &= DIAG(hkl_unit_compatible(NULL, NULL));
47 ok(res == TRUE, __func__);
50 static void factor(void)
52 is_double(HKL_DEGTORAD, hkl_unit_factor(&hkl_unit_angle_deg, &hkl_unit_angle_rad), HKL_EPSILON, __func__);
53 is_double(1e3, hkl_unit_factor(&hkl_unit_angle_rad, &hkl_unit_angle_mrad), HKL_EPSILON, __func__);
54 is_double(1.0,
55 hkl_unit_factor(&hkl_unit_angle_rad, &hkl_unit_angle_mrad) * hkl_unit_factor(&hkl_unit_angle_mrad, &hkl_unit_angle_rad),
56 HKL_EPSILON, __func__);
59 int main(void)
61 plan(4);
63 compatible();
64 factor();
66 return 0;