How to test if my program for SPI communication is working correctly?
The Arduino DUE uses a slightly different methodology for SPI compared to the rest of the Arduino boards.  It handles the operation of the SS line for you, so you don't have to.

While you can use the manual software method, it's better to use the hardware facilities where available.


  The Arduino Due's SPI interface works differently than any other Arduino boards. The library can be used on the Due with the same methods available to other Arduino boards or using the extended methods. The extended methods exploits the the SAM3X hardware and allows some interesting features like:
  
  
  automatic handling of the device slave selection.
  automatic handling of different device configurations (clock speed, data mode, etc) so every device can have its own configuration automatically selected. 
  
  
  Arduino Due has three exposed pins for the devices Slave Select (SS) lines (pins 4, 10, and 52). 


What this means is you initialize the SPI with the SS pin you are using:

SPI.begin(10);


Then you send and receive using the "continuation" versions of the SPI transfer function:

SPI.transfer(10, 0, SPI_CONTINUE);
SPI.transfer(10, value);


The first parameter is the SS pin (it's used as a key to connect the function to the right SPI instance), the second is the value to transfer, and the third tells SPI not to raise the SS pin after transfer.

The SPI on the Due is a single SPI bus with multiple hardware SS pins.  The configuration of the bus is attached to that SS pin, so when you activate an SS pin it automatically configures the bus to the settings you have associated with that SS pin.  This allows one bus to have multiple different settings (speed, clock polarity, bit order, etc) and switch between them properly without any manual intervention on your part.

You can read more about this way of working here: http://arduino.cc/en/Reference/DueExtendedSPI

As for testing your code, when I need to test an SPI port I usually create a loopback connection (connect MOSI to MISO) and send random values through it, receiving what is sent.  The sent value and received value should match if the SPI is working properly.