Skip to content

Commit

Permalink
fits: testcase for nasty nom-tam-fits v1.15.2 behaviour
Browse files Browse the repository at this point in the history
Add testcase that tests for unwanted quote manipulation when
constructing a string-valued header using nom.tam.fits.HeaderCard.

This works fine with the ancient bundled nom.tam.fits (v0.96?)
but will fail if used with the newer nom-tam-fits v1.15.2.
See nom-tam-fits/nom-tam-fits#148
  • Loading branch information
mbtaylor committed Dec 18, 2020
1 parent 3a98db9 commit 451c34d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions fits/src/testcases/uk/ac/starlink/fits/TamfitsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public void testString() throws Exception {
}
}


private void checkStringCard( HeaderCard card ) {
String image = card.toString();
assertEquals( 80, image.length() );
Expand All @@ -93,6 +94,24 @@ private void checkStringCard( HeaderCard card ) {
}
}

public void testStringValues() throws Exception {
checkStringValue( "electron'.s**-1" );
checkStringValue( "x'electron'.s**-1" );

// This one fails for nom.tam.fits 1.15.2;
// the HeaderCard constructor checks for a quote at the start of
// the string and assumes that you have pre-quoted the value,
// tries to strip quotes from start and end, and fails if
// it can't. That is horrible behaviour.
// See https://github.com/nom-tam-fits/nom-tam-fits/issues/148
checkStringValue( "'electron'.s**-1" );
}

private void checkStringValue( String sval ) throws Exception {
HeaderCard card = new HeaderCard( "CARD", sval, "comment" );
assertEquals( sval, card.getValue() );
}

private static String repeat( String txt, int count ) {
StringBuffer sbuf = new StringBuffer( txt.length() * count );
for ( int i = 0; i < count; i++ ) {
Expand Down

0 comments on commit 451c34d

Please sign in to comment.