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
5using namespace Catch::Matchers;
6
7#include "../../../../include/ioutils/fits/fitsHeader.hpp"
8using namespace mx::fits;
9
10#include "../../../../include/improc/eigenImage.hpp"
11
12namespace mx
13{
14namespace unitTest
15{
16namespace fitsTest
17{
18namespace fitsHeaderTest
19{
20
21/// Test functionality of headersToValues
22/**
23 *
24 * \ingroup fitsHeader_unit_tests
25 */
26TEST_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
error_t
The mxlib error codes.
Definition error_t.hpp:26
TEST_CASE("Test functionality of headersToValues", "[ioutils::fits::fitsHeader]")
Test functionality of 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.
The mxlib c++ namespace.
Definition mxlib.hpp:37