rename hkl_engine_pseudo_axes_get -> hkl_engine_pseudo_axes_names_get
[hkl.git] / tests / hkl-parameter-t.c
blob332bb7ffd015cdd3c0a3e59897f810e85d605508
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-2013 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>
26 #include "hkl-parameter-private.h"
28 static void new(void)
30 HklParameter *p;
32 ok(NULL == hkl_parameter_new("", 2, 1, 3,
33 HKL_FALSE, HKL_TRUE,
34 &hkl_unit_angle_rad, &hkl_unit_angle_deg), __func__);
35 ok(NULL == hkl_parameter_new("", 2, 1, 3,
36 HKL_FALSE, HKL_TRUE,
37 &hkl_unit_angle_rad, &hkl_unit_angle_deg), __func__);
38 ok(NULL == hkl_parameter_new("", 2, 1, 3,
39 HKL_FALSE, HKL_TRUE,
40 &hkl_unit_angle_rad, &hkl_unit_angle_deg), __func__);
41 ok(NULL == hkl_parameter_new("toto", 2, 1, 3,
42 HKL_FALSE, HKL_TRUE,
43 &hkl_unit_angle_rad, &hkl_unit_angle_deg), __func__);
45 ok(NULL == hkl_parameter_new("toto", 1, 2, 3,
46 HKL_FALSE, HKL_TRUE,
47 &hkl_unit_angle_rad, &hkl_unit_length_nm), __func__);
49 p = hkl_parameter_new("toto", 1, 2, 3,
50 HKL_FALSE, HKL_TRUE,
51 &hkl_unit_angle_rad, &hkl_unit_angle_deg);
52 ok(0 == !p, __func__);
53 is_double(1., p->range.min, HKL_EPSILON, __func__);
54 is_double(2., p->_value, HKL_EPSILON, __func__);
55 is_double(3., p->range.max, HKL_EPSILON, __func__);
56 ok(HKL_FALSE == p->fit, __func__);
57 ok(HKL_TRUE == p->changed, __func__);
58 ok(&hkl_unit_angle_rad == p->unit, __func__);
59 ok(&hkl_unit_angle_deg == p->punit, __func__);
61 hkl_parameter_free(p);
64 static void new_copy(void)
66 HklParameter *copy, *p;
68 p = hkl_parameter_new("toto", 1, 2, 3,
69 HKL_FALSE, HKL_TRUE,
70 &hkl_unit_angle_rad, &hkl_unit_angle_deg);
72 copy = hkl_parameter_new_copy(p);
74 ok(copy->name == p->name, __func__);
75 is_double(copy->range.min, p->range.min, HKL_EPSILON, __func__);
76 is_double(copy->_value, p->_value, HKL_EPSILON, __func__);
77 is_double(copy->range.max, p->range.max, HKL_EPSILON, __func__);
78 ok(copy->fit == p->fit, __func__);
79 ok(copy->changed == p->changed, __func__);
80 ok(&hkl_unit_angle_rad == copy->unit, __func__);
81 ok(&hkl_unit_angle_deg == copy->punit, __func__);
83 hkl_parameter_free(copy);
84 hkl_parameter_free(p);
87 static void init(void)
89 HklParameter *p;
91 ok(NULL == hkl_parameter_new("", 2, 1, 3,
92 HKL_FALSE, HKL_TRUE,
93 &hkl_unit_angle_rad, &hkl_unit_angle_deg), __func__);
94 ok(NULL == hkl_parameter_new("", 2, 1, 3,
95 HKL_FALSE, HKL_TRUE,
96 &hkl_unit_angle_rad, &hkl_unit_angle_deg), __func__);
97 ok(NULL == hkl_parameter_new("", 2, 1, 3,
98 HKL_FALSE, HKL_TRUE,
99 &hkl_unit_angle_rad, &hkl_unit_angle_deg), __func__);
100 ok(NULL == hkl_parameter_new("toto", 2, 1, 3,
101 HKL_FALSE, HKL_TRUE,
102 &hkl_unit_angle_rad, &hkl_unit_angle_deg), __func__);
103 ok(NULL == hkl_parameter_new("toto", 1, 2, 3,
104 HKL_FALSE, HKL_TRUE,
105 &hkl_unit_angle_rad, &hkl_unit_length_nm), __func__);
106 p = hkl_parameter_new("toto", 1, 2, 3,
107 HKL_FALSE, HKL_TRUE,
108 &hkl_unit_angle_rad, &hkl_unit_angle_deg);
109 ok(NULL != p, __func__);
111 hkl_parameter_free(p);
114 static void is_valid(void)
116 HklParameter *p;
118 p = hkl_parameter_new("toto", 1, 2, 3,
119 HKL_FALSE, HKL_TRUE,
120 &hkl_unit_angle_rad, &hkl_unit_angle_deg);
121 ok(HKL_TRUE == hkl_parameter_is_valid(p), __func__);
123 hkl_parameter_value_set(p, 10, NULL);
124 ok(HKL_FALSE == hkl_parameter_is_valid(p), __func__);
126 hkl_parameter_free(p);
129 int main(int argc, char** argv)
131 plan(29);
133 new();
134 new_copy();
135 init();
136 is_valid();
138 return 0;