Sha256: a1a0ea1101d33d9c985a8202247ccee767934d857e12972b0387f51322d08cfc

Contents?: true

Size: 1.96 KB

Versions: 213

Compression:

Stored size: 1.96 KB

Contents

module crypto;


unittest
{
immutable int allTestsEnabled = 0;

// normalize_strange_characters
{
	auto theCipher = new Cipher("s#$%^&plunk");
	assert("splunk" == theCipher.normalizePlainText());
}

static if (allTestsEnabled)
{
// normalize_numbers
{
	auto theCipher = new Cipher("1, 2, 3 GO!");
	assert("123go" == theCipher.normalizePlainText());
}

// size_of_small_square
{
	auto theCipher = new Cipher("1234");
	assert(2U == theCipher.size());
}

// size_of_slightly_larger_square
{
	auto theCipher = new Cipher("123456789");
	assert(3U == theCipher.size());
}

// size_of_non_perfect_square
{
	auto theCipher = new Cipher("123456789abc");
	assert(4U == theCipher.size());
}

// size_of_non_perfect_square_less
{
	auto theCipher = new Cipher("zomgzombies");
	assert(4U == theCipher.size());
}

// plain_text_segments_from_phrase
{
	const string[] expected = ["neverv", "exthin", "eheart", "withid", "lewoes"];
	auto theCipher = new Cipher("Never vex thine heart with idle woes");
	const auto actual = theCipher.plainTextSegments();

	assert(expected == actual);
}

// plain_text_segments_from_complex_phrase
{
	const string[] expected = ["zomg", "zomb", "ies"];
	auto theCipher = new Cipher("ZOMG! ZOMBIES!!!");
	const auto actual = theCipher.plainTextSegments();

	assert(expected == actual);
}

// Cipher_text_short_phrase
{
	auto theCipher = new Cipher("Time is an illusion. Lunchtime doubly so.");
	assert("tasneyinicdsmiohooelntuillibsuuml" == theCipher.cipherText());
}

// Cipher_text_long_phrase
{
	auto theCipher = new Cipher("We all know interspecies romance is weird.");
	assert("wneiaweoreneawssciliprerlneoidktcms" == theCipher.cipherText());
}

// normalized_Cipher_text1
{
	auto theCipher = new Cipher("Madness, and then illumination.");
	assert("msemo aanin dnin ndla etlt shui" == theCipher.normalize.cipherText());
}

// normalized_Cipher_text2
{
	auto theCipher = new Cipher("Vampires are people too!");
	assert("vrel aepe mset paoo irpo" == theCipher.normalize.cipherText());
}
}

}

Version data entries

213 entries across 213 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.138 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.137 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.136 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.135 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.134 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.133 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.132 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.131 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.130 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.129 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.128 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.127 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.126 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.125 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.124 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.123 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.122 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.121 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.120 tracks/d/exercises/crypto-square/source/crypto_square.d