public static void testCorrectness(boolean isBWT)
    {
        System.out.println("\nBWT"+(!isBWT?"S":"")+" Correctness test");

        // Test behavior
        for (int ii=1; ii<=20; ii++)
        {
            System.out.println("\nTest "+ii);
            int start = 0;
            byte[] buf1;
            Random rnd = new Random();

            if (ii == 1)
            {
               buf1 = "mississippi".getBytes();
            }
            else if (ii == 2)
            {
               buf1 = "3.14159265358979323846264338327950288419716939937510".getBytes();
            }
            else if (ii == 3)
            {
               buf1 = "SIX.MIXED.PIXIES.SIFT.SIXTY.PIXIE.DUST.BOXES".getBytes();
            }
            else
            {
               buf1 = new byte[128];

               for (int i=0; i<buf1.length; i++)
               {
                   buf1[i] = (byte) (65 + rnd.nextInt(4*ii));
               }
            }

            byte[] buf2 = new byte[buf1.length];
            byte[] buf3 = new byte[buf1.length];
            SliceByteArray sa1 = new SliceByteArray(buf1, 0);
            SliceByteArray sa2 = new SliceByteArray(buf2, 0);
            SliceByteArray sa3 = new SliceByteArray(buf3, 0);
            ByteTransform bwt = (isBWT) ? new BWT() : new BWTS();
            String str1 = new String(buf1, start, buf1.length-start);
            System.out.println("Input:   "+str1);
            sa1.index = start;
            sa2.index = 0;
            bwt.forward(sa1, sa2);
            String str2 = new String(buf2);
            System.out.print("Encoded: "+str2);
            
            if (isBWT)
            {
               int primaryIndex = ((BWT) bwt).getPrimaryIndex();
               System.out.println("  (Primary index="+primaryIndex+")");
               ((BWT) bwt).setPrimaryIndex(primaryIndex);
            }
            else
            {
               System.out.println("");
            }
            
            sa2.index = 0;
            sa3.index = start;
            
            bwt.inverse(sa2, sa3);
            String str3 = new String(buf3, start, buf3.length-start);
            System.out.println("Output:  "+str3);

            if (str1.equals(str3) == true)
               System.out.println("Identical");
            else
            {
               System.out.println("Different");
               System.exit(1);
            }
        }
    }