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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
package com.rockymadden.stringmetric.cli.similarity
import com.rockymadden.stringmetric.cli.ScalaTest
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
final class weightedlevenshteinmetricSpec extends ScalaTest { "weightedlevenshteinmetric" should provide {
"main method" when passed {
"valid dashless arguments and valid weight arguments" should executes {
"print if they are a match" in {
val out = new java.io.ByteArrayOutputStream()
Console.withOut(out)(
weightedlevenshteinmetric.main(
Array(
"--unitTest",
"--debug",
"--deleteWeight=1",
"--insertWeight=1",
"--substituteWeight=1",
"abc",
"abc"
)
)
)
out.toString should equal ("0.0\n")
out.reset()
Console.withOut(out)(
weightedlevenshteinmetric.main(
Array(
"--unitTest",
"--debug",
"--deleteWeight=2",
"--insertWeight=2",
"--substituteWeight=1",
"abc",
"xyz"
)
)
)
out.toString should equal ("3.0\n")
out.reset()
Console.withOut(out)(
weightedlevenshteinmetric.main(
Array(
"--unitTest",
"--debug",
"--deleteWeight=2",
"--insertWeight=1",
"--substituteWeight=2",
"xyz",
"xyzxyz"
)
)
)
out.toString should equal ("3.0\n")
out.reset()
Console.withOut(out)(
weightedlevenshteinmetric.main(
Array(
"--unitTest",
"--debug",
"--deleteWeight=1",
"--insertWeight=2",
"--substituteWeight=2",
"xyzxyz",
"xyz"
)
)
)
out.toString should equal ("3.0\n")
out.reset()
}
}
"valid dashless arguments and invalid weight arguments" should throws {
"IllegalArgumentException" in {
evaluating {
weightedlevenshteinmetric.main(
Array(
"--unitTest",
"--debug",
"--deleteWeight=1",
"--substituteWeight=1",
"abc",
"abc"
)
)
} should produce [IllegalArgumentException]
evaluating {
weightedlevenshteinmetric.main(
Array(
"--unitTest",
"--debug",
"--deleteWeight=1",
"--insertWeight=q",
"--substituteWeight=1",
"abc",
"abc"
)
)
} should produce [IllegalArgumentException]
}
}
"no dashless arguments" should throws {
"IllegalArgumentException" in {
evaluating {
weightedlevenshteinmetric.main(Array("--unitTest", "--debug"))
} should produce [IllegalArgumentException]
}
}
}
}}
|