Fixed breaking test (erroneously detecting ANSI environment) and mis-colorized space at the end of the bit string, at the CHECKSUM
This commit is contained in:
parent
c3d2c68860
commit
f167b704bf
|
@ -90,23 +90,27 @@ public class Dice8EntropyGenerator {
|
||||||
int entropyBitIndex = entropyBitString.length() - currentRollSetBitString.length() + rollSetBitIndex;
|
int entropyBitIndex = entropyBitString.length() - currentRollSetBitString.length() + rollSetBitIndex;
|
||||||
|
|
||||||
if (entropyBitIndex < targetBitsOfEntropy)
|
if (entropyBitIndex < targetBitsOfEntropy)
|
||||||
rollSetBitsLine.append(styleBit(rollSetBitIndex, "" + currentRollSetBitString.charAt(rollSetBitIndex)));
|
rollSetBitsLine.append(styleBit("" + currentRollSetBitString.charAt(rollSetBitIndex), entropyBitIndex, rollSetBitIndex));
|
||||||
else
|
else
|
||||||
rollSetBitsLine.append("-");
|
rollSetBitsLine.append("-");
|
||||||
|
|
||||||
if (rollSetBitIndex == 32) rollSetBitsLine.append("|");
|
if (rollSetBitIndex == 32)
|
||||||
else if (rollSetBitIndex % 3 == 2) rollSetBitsLine.append(styleBit(rollSetBitIndex, " "));
|
rollSetBitsLine.append("|");
|
||||||
else if (rollSetBitIndex % 11 == 10) rollSetBitsLine.append(" | ");
|
else if (rollSetBitIndex % 3 == 2)
|
||||||
|
rollSetBitsLine.append(styleBit(" ", entropyBitIndex, rollSetBitIndex));
|
||||||
|
else if (rollSetBitIndex % 11 == 10)
|
||||||
|
rollSetBitsLine.append(" | ");
|
||||||
}
|
}
|
||||||
|
|
||||||
return rollSetBitsLine;
|
return rollSetBitsLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String styleBit(int rollSetBitIndex, String s) {
|
private String styleBit(String bit, int globalEntropyBitIndex, int currentRollSetBitIndex) {
|
||||||
|
|
||||||
if (!ansiColorOutput) return s;
|
if (!ansiColorOutput || globalEntropyBitIndex >= targetBitsOfEntropy)
|
||||||
|
return bit;
|
||||||
|
|
||||||
return getBitFormat(rollSetBitIndex).format(s);
|
return getBitFormat(currentRollSetBitIndex).format(bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AnsiFormat getBitFormat(int rollSetBitIndex) {
|
private AnsiFormat getBitFormat(int rollSetBitIndex) {
|
||||||
|
|
|
@ -10,6 +10,8 @@ class mnemonic_8_sided_dice_tests extends CliTestFixture {
|
||||||
@Test
|
@Test
|
||||||
void with_arguments_interactive_8_sided_dice_should_generate_mnemonic_sentence() throws UnsupportedEncodingException {
|
void with_arguments_interactive_8_sided_dice_should_generate_mnemonic_sentence() throws UnsupportedEncodingException {
|
||||||
|
|
||||||
|
System.setProperty("picocli.ansi", "false");
|
||||||
|
|
||||||
withArgs("mnemonic -i8 --bits 128");
|
withArgs("mnemonic -i8 --bits 128");
|
||||||
|
|
||||||
expectedOutput("Input 11 x 8-sided dice rolls [1-8]: ");
|
expectedOutput("Input 11 x 8-sided dice rolls [1-8]: ");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user