Skip to content

Commit 9851bec

Browse files
committedFeb 17, 2018
Update crypto-square exercise to match latest canonical json.
Refs exercism#488
1 parent 56479ec commit 9851bec

File tree

2 files changed

+21
-42
lines changed

2 files changed

+21
-42
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,43 @@
11
import org.scalatest.{Matchers, FunSuite}
22

3-
/** @version 2.0.0 */
3+
/** @version 3.2.0 */
44
class CryptoSquareTest extends FunSuite with Matchers {
55

6-
test("Lowercase") {
7-
CryptoSquare.normalizedPlaintext("Hello") should be ("hello")
8-
}
9-
10-
test("Remove spaces") {
11-
pending
12-
CryptoSquare.normalizedPlaintext("Hi there") should be ("hithere")
13-
}
14-
15-
test("Remove punctuation") {
16-
pending
17-
CryptoSquare.normalizedPlaintext("@1, 2%, 3 Go!") should be ("123go")
18-
}
19-
20-
test("empty plaintext results in an empty rectangle") {
21-
pending
22-
CryptoSquare.plaintextSegments("") should be (List())
23-
}
24-
25-
test("4 character plaintext results in an 2x2 rectangle") {
26-
pending
27-
CryptoSquare.plaintextSegments("Ab Cd") should be (List("ab", "cd"))
28-
}
29-
30-
test("9 character plaintext results in an 3x3 rectangle") {
31-
pending
32-
CryptoSquare.plaintextSegments("This is fun!") should be (List("thi", "sis", "fun"))
6+
test("empty plaintext results in an empty ciphertext") {
7+
CryptoSquare.ciphertext("") should be("")
338
}
349

35-
test("54 character plaintext results in an 8x7 rectangle") {
10+
test("Lowercase") {
3611
pending
37-
CryptoSquare.plaintextSegments("If man was meant to stay on the ground, god would have given us roots.") should be (List("ifmanwas", "meanttos", "tayonthe", "groundgo", "dwouldha", "vegivenu", "sroots"))
12+
CryptoSquare.ciphertext("A") should be("a")
3813
}
3914

40-
test("empty plaintext results in an empty encode") {
15+
test("Remove spaces") {
4116
pending
42-
CryptoSquare.encoded("") should be ("")
17+
CryptoSquare.ciphertext(" b ") should be("b")
4318
}
4419

45-
test("Non-empty plaintext results in the combined plaintext segments") {
20+
test("Remove punctuation") {
4621
pending
47-
CryptoSquare.encoded("If man was meant to stay on the ground, god would have given us roots.") should be ("imtgdvsfearwermayoogoanouuiontnnlvtwttddesaohghnsseoau")
22+
CryptoSquare.ciphertext("@1,%!") should be("1")
4823
}
4924

50-
test("empty plaintext results in an empty ciphertext") {
25+
test("9 character plaintext results in 3 chunks of 3 characters") {
5126
pending
52-
CryptoSquare.ciphertext("") should be ("")
27+
CryptoSquare.ciphertext("This is fun!") should be("tsf hiu isn")
5328
}
5429

55-
test("9 character plaintext results in 3 chunks of 3 characters") {
30+
test(
31+
"8 character plaintext results in 3 chunks, the last one with a trailing space") {
5632
pending
57-
CryptoSquare.ciphertext("This is fun!") should be ("tsf hiu isn")
33+
CryptoSquare.ciphertext("Chill out.") should be("clu hlt io ")
5834
}
5935

60-
test("54 character plaintext results in 7 chunks, the last two padded with spaces") {
36+
test(
37+
"54 character plaintext results in 7 chunks, the last two with trailing spaces") {
6138
pending
62-
CryptoSquare.ciphertext("If man was meant to stay on the ground, god would have given us roots.") should be ("imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau ")
39+
CryptoSquare.ciphertext(
40+
"If man was meant to stay on the ground, god would have given us roots.") should be(
41+
"imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau ")
6342
}
64-
}
43+
}

‎testgen/src/main/scala/CryptoSquareTestGenerator.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object CryptoSquareTestGenerator {
88
val file = new File("src/main/resources/crypto-square.json")
99

1010
val code = TestSuiteBuilder.build(file,
11-
fromLabeledTestAlt("normalizedPlaintext" -> Seq("plaintext"), "plaintextSegments" -> Seq("plaintext"),
11+
fromLabeledTestAltFromInput("normalizedPlaintext" -> Seq("plaintext"), "plaintextSegments" -> Seq("plaintext"),
1212
"encoded" -> Seq("plaintext"), "ciphertext" -> Seq("plaintext")))
1313
println(s"-------------")
1414
println(code)

0 commit comments

Comments
 (0)
Please sign in to comment.