57 fits_create_img( m_file, BYTE_IMG, 1, axes, &status );
90TEST_CASE(
"Round-tripping native FITS header card values",
"[ioutils::fits::fitsHeaderCard]" )
93 REQUIRE( empty.
keyword().empty() );
99 fitsHeaderCard<> unsignedCharacter(
"UCHAR",
static_cast<unsigned char>( 13 ),
"uchar" );
100 fitsHeaderCard<> shortInteger(
"SHORT",
static_cast<short>( 14 ),
"short" );
101 fitsHeaderCard<> unsignedShort(
"USHORT",
static_cast<unsigned short>( 15 ),
"ushort" );
107 fitsHeaderCard<> unsignedLongLong(
"ULONGLONG", 21ULL,
"unsigned long long" );
110 fitsHeaderCard<> complexSingle(
"COMPLEXF", std::complex<float>( 1.0F, -2.0F ),
"complex float" );
111 fitsHeaderCard<> complexReal(
"COMPLEXD", std::complex<double>( 3.0, -4.0 ),
"complex double" );
112 fitsHeaderCard<> extended(
"LONGDOUBLE",
static_cast<long double>( 5.0 ),
"long double" );
115 std::complex<long double>(
static_cast<long double>( 6.0 ),
static_cast<long double>( -7.0 ) ),
116 "complex long double" );
121 std::complex<__float128>(
static_cast<__float128
>( 9.0 ),
static_cast<__float128
>( -10.0 ) ),
126 REQUIRE( character.
Char( &
error ) == 12 );
128 REQUIRE( unsignedCharacter.
UChar() == 13 );
129 REQUIRE( shortInteger.
Short() == 14 );
130 REQUIRE( unsignedShort.
UShort() == 15 );
131 REQUIRE( integer.
Int() == 16 );
132 REQUIRE( unsignedInteger.
UInt() == 17U );
133 REQUIRE( longInteger.
Long() == 18L );
134 REQUIRE( unsignedLong.
ULong() == 19UL );
135 REQUIRE( longLongInteger.
LongLong() == 20LL );
136 REQUIRE( unsignedLongLong.
ULongLong() == 21ULL );
137 REQUIRE( single.
Float() == 22.5F );
138 REQUIRE( real.
Double() == 23.5 );
140 REQUIRE( character.
valueStr() ==
"12" );
141 REQUIRE( unsignedCharacter.
valueStr() ==
"13" );
142 REQUIRE( shortInteger.
valueStr() ==
"14" );
143 REQUIRE( unsignedShort.
valueStr() ==
"15" );
144 REQUIRE( integer.
valueStr() ==
"16" );
145 REQUIRE( unsignedInteger.
valueStr() ==
"17" );
146 REQUIRE( longInteger.
valueStr() ==
"18" );
147 REQUIRE( unsignedLong.
valueStr() ==
"19" );
148 REQUIRE( longLongInteger.
valueStr() ==
"20" );
149 REQUIRE( unsignedLongLong.
valueStr() ==
"21" );
150 REQUIRE( single.
valueStr() ==
"22.5" );
151 REQUIRE( real.
valueStr() ==
"23.5" );
152 REQUIRE( complexSingle.
valueStr() ==
"(1,-2)" );
153 REQUIRE( complexReal.
valueStr() ==
"(3,-4)" );
162 REQUIRE( copied.
keyword() ==
"DOUBLE" );
163 REQUIRE( copied.
Double() == 23.5 );
164 REQUIRE( copied.
comment() ==
"double" );
167 assigned = unsignedLongLong;
168 REQUIRE( assigned.
keyword() ==
"ULONGLONG" );
169 REQUIRE( assigned.
ULongLong() == 21ULL );
170 REQUIRE( assigned.
comment() ==
"unsigned long long" );
172 REQUIRE( assigned.
ULongLong() == 21ULL );
176 REQUIRE( assigned.
keyword() ==
"RENAMED" );
177 REQUIRE( assigned.
comment() ==
"updated" );
297TEST_CASE(
"Rejecting unsupported FITS header card conversions",
"[ioutils::fits::fitsHeaderCard]" )
300 testHeaderCard<> source;
302 source.forceTypeWithValue(
fitsType<std::complex<float>>() );
303 REQUIRE( source.Int( &
error ) == 0 );
305 source.forceTypeWithValue(
fitsType<std::complex<double>>() );
306 REQUIRE( source.Int( &
error ) == 0 );
309 REQUIRE( source.Int( &
error ) == 0 );
312 REQUIRE( source.Int( &
error ) == 0 );
315 REQUIRE( source.Int( &
error ) == 0 );
318 REQUIRE( source.Int( &
error ) == 0 );
320 source.forceTypeWithValue( -12345 );
321 REQUIRE( source.Int( &
error ) == 0 );
324 source.forceTypeWithValue(
fitsType<std::complex<float>>() );
335 testHeaderCard<> special;
338 special.forceTypeWithValue( type );
339 REQUIRE( special.String( &
error ).empty() );
344 REQUIRE( special.String( &
error ).empty() );
346 REQUIRE( special.valueStrGood() );
348 special.forceTypeWithValue( -12345 );
349 REQUIRE( special.String( &
error ).empty() );
359 testHeaderCard<> missingString;