4.11.  Comparing Named Destinations

Named Destinations are seldom a test goal, because until now no test tool is been available which could compare named destinations. With PDFUnit you can verify that two documents have the same named destinations.

Quantity

A simple test is to compare the number of Named Destinations in two documents:

@Test
public void compareNumberOfNamedDestinations() throws Exception {
  String filenameTest = "documentUnderTest.pdf";
  String filenameReference = "reference.pdf";
  
  AssertThat.document(filenameTest)
            .and(filenameReference) 
            .haveSameNumberOfNamedDestinations()
  ;
}

Names and Internal Position

If the names of 'Named Destinations' have to be equal for two documents, the following test can be used:

@Test
public void compareNamedDestinations() throws Exception {
  String filenameTest = "documentUnderTest.pdf";
  String filenameReference = "reference.pdf";
  
  AssertThat.document(filenameTest)
            .and(filenameReference) 
            .haveSameNamedDestinations()
  ;
}