trailling spaces
[hkl.git] / tests / hkl-pseudoaxis-zaxis-t.c
blobdccc48f127be705cac996f2e52a2fceb1eb39acc
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/hkl-tap.h>
26 static void solution(void)
28 int res = HKL_TRUE;
29 HklEngineList *engines;
30 HklEngine *engine;
31 const HklFactory *factory;
32 HklGeometry *geometry;
33 const HklGeometryList *geometries;
34 HklDetector *detector;
35 HklSample *sample;
36 HklLattice *lattice;
37 static double hkl[] = {1, 1, 0};
38 HklParameterList *pseudo_axes;
39 HklMatrix *U;
41 /* get the geometry and set the source */
42 factory = hkl_factory_get_by_name("ZAXIS");
43 geometry = hkl_factory_create_new_geometry(factory);
44 hkl_geometry_wavelength_set(geometry, 0.842);
46 /* set up the sample */
47 sample = hkl_sample_new("test");
48 lattice = hkl_lattice_new(5.432, 5.432, 5.432,
49 90 * HKL_DEGTORAD,
50 90 * HKL_DEGTORAD,
51 90 * HKL_DEGTORAD);
52 hkl_sample_lattice_set(sample, lattice);
53 U = hkl_matrix_new_euler(-90*HKL_DEGTORAD, 0, 0);
54 hkl_sample_U_set(sample, U);
55 hkl_lattice_free(lattice);
56 hkl_matrix_free(U);
58 /* use a 0D detector */
59 detector = hkl_detector_factory_new(HKL_DETECTOR_TYPE_0D);
60 hkl_detector_idx_set(detector, 1);
62 /* select the hkl pseudo axis */
63 engines = hkl_factory_create_new_engine_list(factory);
64 hkl_engine_list_init(engines, geometry, detector, sample);
65 geometries = hkl_engine_list_geometries(engines);
66 engine = hkl_engine_list_get_by_name(engines, "hkl");
67 pseudo_axes = hkl_engine_pseudo_axes(engine);
69 /* the init part must succed */
70 hkl_geometry_set_values_unit_v(geometry, 1., 0., 0., 0.);
72 /* compute the 1 1 0 */
73 hkl_parameter_list_values_set(pseudo_axes, hkl, ARRAY_SIZE(hkl), NULL);
74 if (hkl_engine_set(engine, NULL)){
75 const darray_item *items = hkl_geometry_list_items_get(geometries);
76 HklGeometryListItem **item;
78 darray_foreach(item, *items){
79 static double null[] = {0, 0, 0};
81 hkl_parameter_list_values_set(pseudo_axes, null, ARRAY_SIZE(null), NULL);
82 hkl_geometry_set(geometry,
83 hkl_geometry_list_item_geometry_get(*item));
84 hkl_engine_get(engine, NULL);
85 res &= check_pseudoaxes(engine, hkl, 3);
87 }else
88 res = HKL_FALSE;
89 if(!res)
90 hkl_engine_fprintf(stdout, engine);
92 hkl_engine_list_free(engines);
93 hkl_detector_free(detector);
94 hkl_sample_free(sample);
95 hkl_geometry_free(geometry);
97 ok(res == HKL_TRUE, "solution");
100 int main(int argc, char** argv)
102 plan(1);
104 solution();
106 return 0;