* add the first HklSample structure.
[hkl.git] / test / hkl-test-sample.c
blob8c2c3ee7e5d9302631d3a8883de8097e14616bc3
1 #include <math.h>
3 #include <hkl/hkl-sample.h>
4 #include <hkl/hkl-geometry-factory.h>
6 #include "hkl-test.h"
8 #ifdef HKL_TEST_SUITE_NAME
9 # undef HKL_TEST_SUITE_NAME
10 #endif
11 #define HKL_TEST_SUITE_NAME sample
13 HKL_TEST_SUITE_FUNC(new)
15 HklDetector *det;
16 HklGeometry *geom;
17 HklSample *sample;
19 det = hkl_detector_new();
20 geom = hkl_geometry_factory_new(HKL_GEOMETRY_EULERIAN4C_VERTICAL);
21 sample = hkl_sample_new("test", HKL_SAMPLE_MONOCRYSTAL);
23 hkl_sample_free(sample);
24 hkl_detector_free(det);
25 hkl_geometry_free(geom);
27 return HKL_TEST_PASS;
30 HKL_TEST_SUITE_FUNC(add_reflection)
32 HklDetector *det;
33 HklGeometry *geom;
34 HklSample *sample;
35 HklSampleReflection *ref;
37 det = hkl_detector_new();
38 geom = hkl_geometry_factory_new(HKL_GEOMETRY_EULERIAN4C_VERTICAL);
39 det->idx = 1;
40 sample = hkl_sample_new("test", HKL_SAMPLE_MONOCRYSTAL);
42 ref = hkl_sample_add_reflection(sample, geom, det, 1, 0, 0);
44 hkl_sample_free(sample);
45 hkl_detector_free(det);
46 hkl_geometry_free(geom);
48 return HKL_TEST_PASS;
51 HKL_TEST_SUITE_FUNC(get_reflection)
53 HklDetector *det;
54 HklGeometry *geom;
55 HklSample *sample;
56 HklSampleReflection *ref;
57 HklSampleReflection *ref2;
59 det = hkl_detector_new();
60 geom = hkl_geometry_factory_new(HKL_GEOMETRY_EULERIAN4C_VERTICAL);
61 det->idx = 1;
62 sample = hkl_sample_new("test", HKL_SAMPLE_MONOCRYSTAL);
64 ref = hkl_sample_add_reflection(sample, geom, det, 1, 0, 0);
65 ref2 = hkl_sample_get_reflection(sample, 0);
67 HKL_ASSERT_EQUAL(ref, ref2);
69 hkl_sample_free(sample);
70 hkl_detector_free(det);
71 hkl_geometry_free(geom);
73 return HKL_TEST_PASS;
76 HKL_TEST_SUITE_FUNC(del_reflection)
78 HklDetector *det;
79 HklGeometry *geom;
80 HklSample *sample;
81 HklSampleReflection *ref;
83 det = hkl_detector_new();
84 geom = hkl_geometry_factory_new(HKL_GEOMETRY_EULERIAN4C_VERTICAL);
85 det->idx = 1;
86 sample = hkl_sample_new("test", HKL_SAMPLE_MONOCRYSTAL);
88 ref = hkl_sample_add_reflection(sample, geom, det, 1, 0, 0);
89 hkl_sample_del_reflection(sample, 0);
90 HKL_ASSERT_EQUAL(0, sample->reflections->len);
92 hkl_sample_free(sample);
93 hkl_detector_free(det);
94 hkl_geometry_free(geom);
96 return HKL_TEST_PASS;
99 HKL_TEST_SUITE_BEGIN
101 HKL_TEST( new );
102 HKL_TEST( add_reflection );
103 HKL_TEST( get_reflection );
104 HKL_TEST( del_reflection );
106 HKL_TEST_SUITE_END