-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathstrings_test.scala
51 lines (39 loc) · 1.82 KB
/
strings_test.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import org.scalatest._
import strings._
import scala.util.{Try, Success, Failure}
/*
* Note to student: You may not change this file (the tests)
*/
class RationalScalaTestFlatSpecMatchers extends FlatSpec with Matchers {
"these sentences" should "be interrogative" in {
getSentenceType("?") should be ("interrogative")
getSentenceType("Is this a question?") should be ("interrogative")
getSentenceType("Is this a question?#$@#$#??") should be ("interrogative")
getSentenceType("A sentence not ending in ? or other punctuation is not a sentence") should be ("unknown")
}
it should "be declarative" in {
getSentenceType(".") should be ("declarative")
getSentenceType("To be or not to be, that is the question.") should be ("declarative")
getSentenceType("Is this a question?#$@#$#??,.") should be ("declarative")
getSentenceType("A sentence not ending in . or other punctuation is not a sentence") should be ("unknown")
}
it should "be exclamatory" in {
getSentenceType("!") should be ("exclamatory")
getSentenceType("This rocks!") should be ("exclamatory")
getSentenceType("Is this a question?#$@#$#??,.!") should be ("exclamatory")
getSentenceType("A sentence not ending in ! or other punctuation is not a sentence") should be ("unknown")
}
"name formatting" should "handle common case of First Last" in {
getFormattedName("Adam Smith") should be ("Smith, Adam")
}
it should "handle First Middle Last" in {
getFormattedName("George K. Thiruvathukal") should be ("Thiruvathukal, George K.")
getFormattedName("Ludwig van Beethoven") should be ("Beethoven, Ludwig van")
}
it should "handle only one name" in {
getFormattedName("Madonna") should be ("Madonna")
}
it should "handle empty name" in {
getFormattedName("") should be ("")
}
}