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.180 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.179 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.178 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.177 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.176 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.175 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.174 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.173 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.172 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.171 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.170 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.169 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.167 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.166 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.165 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.164 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.163 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.162 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.161 tracks/d/exercises/crypto-square/source/crypto_square.d
trackler-2.2.1.160 tracks/d/exercises/crypto-square/source/crypto_square.d