mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [
git repo
]
Loading...
Searching...
No Matches
fitsHeader_test.cpp
1
/** \file fitsFile_test.cpp
2
*/
3
#include "../../../catch2/catch.hpp"
4
5
using namespace
Catch::Matchers;
6
7
#include "../../../../include/ioutils/fits/fitsHeader.hpp"
8
using namespace
mx::fits;
9
10
#include "../../../../include/improc/eigenImage.hpp"
11
12
namespace
mx
13
{
14
namespace
unitTest
15
{
16
namespace
fitsTest
17
{
18
namespace
fitsHeaderTest
19
{
20
21
/// Test functionality of headersToValues
22
/**
23
*
24
* \ingroup fitsHeader_unit_tests
25
*/
26
TEST_CASE
(
"Test functionality of headersToValues"
,
"[ioutils::fits::fitsHeader]"
)
27
{
28
// to force doxygen linking
29
#ifdef MXLIB_DOXYGEN_PROTECTED_REF
30
#endif
31
32
SECTION(
"a vector of floating point values, no errors"
)
33
{
34
std::vector<fitsHeader<mx::verbose::d>> fhs( 5 );
35
36
fhs[0].append<
float
>(
"KEYTEST"
, 1,
"test comment"
);
37
fhs[1].append<
float
>(
"KEYTEST"
, 2,
"test comment"
);
38
fhs[2].append<
float
>(
"KEYTEST"
, 3,
"test comment"
);
39
fhs[3].append<
float
>(
"KEYTEST"
, 4,
"test comment"
);
40
fhs[4].append<
float
>(
"KEYTEST"
, 5,
"test comment"
);
41
42
std::vector<float> vals;
43
std::vector<size_t> bad;
44
mx::error_t
errc =
headersToValues
( vals, bad, fhs,
"KEYTEST"
);
45
46
REQUIRE( !errc );
47
48
REQUIRE( vals[0] == 1 );
49
REQUIRE( vals[1] == 2 );
50
REQUIRE( vals[2] == 3 );
51
REQUIRE( vals[3] == 4 );
52
REQUIRE( vals[4] == 5 );
53
}
54
55
SECTION(
"a vector of floating point values, no errors"
)
56
{
57
std::vector<fitsHeader<mx::verbose::d>> fhs( 5 );
58
59
fhs[0].append<
float
>(
"KEYTEST"
, 1,
"test comment"
);
60
fhs[1].append<
float
>(
"KEYTEST"
, 2,
"test comment"
);
61
// fhs[2] is not set
62
fhs[3].append<
float
>(
"KEYTEST"
, 4,
"test comment"
);
63
fhs[4].append<
float
>(
"KEYTEST"
, 5,
"test comment"
);
64
65
std::vector<float> vals;
66
std::vector<size_t> bad;
67
mx::error_t
errc =
headersToValues
( vals, bad, fhs,
"KEYTEST"
);
68
69
REQUIRE( !!errc );
70
71
REQUIRE( vals[0] == 1 );
72
REQUIRE( vals[1] == 2 );
73
REQUIRE( vals[2] == std::numeric_limits<float>::max() );
74
REQUIRE( vals[3] == 4 );
75
REQUIRE( vals[4] == 5 );
76
}
77
}
78
79
}
// namespace fitsHeaderTest
80
}
// namespace fitsTest
81
}
// namespace unitTest
82
}
// namespace mx
mx::error_t
error_t
The mxlib error codes.
Definition
error_t.hpp:26
mx::unitTest::fitsTest::fitsHeaderTest::TEST_CASE
TEST_CASE("Test functionality of headersToValues", "[ioutils::fits::fitsHeader]")
Test functionality of headersToValues.
Definition
fitsHeader_test.cpp:26
mx::fits::headersToValues
error_t headersToValues(std::vector< dataT > &v, std::vector< size_t > &bad, std::vector< fitsHeaderT > &heads, const std::string &keyw)
Convert the values in a std::vector of fits headers into a std::vector of values.
Definition
fitsHeader.hpp:893
mx
The mxlib c++ namespace.
Definition
mxlib.hpp:37
tests
include
ioutils
fits
fitsHeader_test.cpp
Generated on Thu Feb 19 2026 23:03:56 for mxlib by
1.9.8