[binoclars-ng] added the tth_azimuth projection for mars.
[hkl.git] / tests / hkl-source-t.c
blob493862ec16a20be28bc1be3050b10230b3d7685b
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-2019 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-source-private.h"
28 static void new_copy(void)
30 HklSource s, c;
32 hkl_source_init(&s, 1.54, 1, 0, 0);
33 c = s;
35 is_double(c.wave_length, s.wave_length, HKL_EPSILON, __func__);
36 ok(FALSE == hkl_vector_cmp(&c.direction, &s.direction), __func__);
39 static void init(void)
41 HklSource s;
43 hkl_source_init(&s, 1, 1, 0, 0);
45 is_double(1., s.wave_length, HKL_EPSILON, __func__);
46 is_double(1., s.direction.data[0], HKL_EPSILON, __func__);
47 is_double(0., s.direction.data[1], HKL_EPSILON, __func__);
48 is_double(0., s.direction.data[2], HKL_EPSILON, __func__);
51 static void cmp(void)
53 HklSource ref, s1, s2;
55 hkl_source_init(&ref, 1.54, 1, 0, 0);
56 hkl_source_init(&s1, 1.54, 1, 0, 0);
57 hkl_source_init(&s2, 1, 1, 0, 0);
59 ok(TRUE == hkl_source_cmp(&ref, &s1), __func__);
60 ok(FALSE == hkl_source_cmp(&ref, &s2), __func__);
63 static void compute_ki(void)
65 HklSource s;
66 HklVector ki_ref = {{HKL_TAU / 1.54, 0, 0}};
67 HklVector ki;
69 hkl_source_init(&s, 1.54, 1, 0, 0);
71 hkl_source_compute_ki(&s, &ki);
72 ok(0 == hkl_vector_cmp(&ki_ref, &ki), __func__);
75 static void get_wavelength(void)
77 HklSource s;
79 hkl_source_init(&s, 1, 1, 0, 0);
81 is_double(1., hkl_source_get_wavelength(&s), HKL_EPSILON, __func__);
84 int main(void)
86 plan(10);
88 new_copy();
89 init();
90 cmp();
91 compute_ki();
92 get_wavelength();
94 return 0;