// Test that the primitive that converts 3 bits to 2 trits works correctly.
@Test public void test_convPolyBinaryToTrinaryHelper()
throws NtruException
{
NtruEncryptKey keys = new NtruEncryptKey(OID.ees401ep1);
short out[] = new short[16];
java.util.Arrays.fill(out, (short) 22); // init to invalid data
// Check each bit pattern in [0..8).
keys.convPolyBinaryToTrinaryHelper(out.length, 0, out, 7);
keys.convPolyBinaryToTrinaryHelper(out.length, 2, out, 6);
keys.convPolyBinaryToTrinaryHelper(out.length, 4, out, 5);
keys.convPolyBinaryToTrinaryHelper(out.length, 6, out, 4);
keys.convPolyBinaryToTrinaryHelper(out.length, 8, out, 3);
keys.convPolyBinaryToTrinaryHelper(out.length, 10, out, 2);
keys.convPolyBinaryToTrinaryHelper(out.length, 12, out, 1);
keys.convPolyBinaryToTrinaryHelper(out.length, 14, out, 0);
// Manually computed expected output
short expectedOut[] = {
-1, 1, -1, 0, 1, -1, 1, 1, 1, 0, 0, -1, 0, 1, 0, 0
};