@@ -11,6 +11,8 @@ import collection.mutable.HashSet
11
11
12
12
class FileSpecificTests extends FreeSpec with PropertyChecks with Matchers {
13
13
14
+ val insertions = 30
15
+
14
16
" persistence" in {
15
17
val f = newfile
16
18
val t = new FileBPlusTree [Int , Any ]( f, 3 )
@@ -26,7 +28,6 @@ class FileSpecificTests extends FreeSpec with PropertyChecks with Matchers {
26
28
" inserting/deleting/retrieving long strings" in {
27
29
val t = new FileBPlusTree [Int , String ]( newfile, 3 )
28
30
val set = new HashSet [String ]
29
- val size = 50
30
31
val len = 500
31
32
32
33
def string : String = {
@@ -40,12 +41,12 @@ class FileSpecificTests extends FreeSpec with PropertyChecks with Matchers {
40
41
}
41
42
}
42
43
43
- for (k <- 1 to size ) {
44
+ for (k <- 1 to insertions ) {
44
45
t.insert( k, string ) shouldBe false
45
46
t.wellConstructed shouldBe " true"
46
47
}
47
48
48
- for (k <- 1 to size / 2 ) {
49
+ for (k <- 1 to insertions / 2 ) {
49
50
t.search( k ) match {
50
51
case None => fail
51
52
case Some ( v ) => set -= v
@@ -55,12 +56,12 @@ class FileSpecificTests extends FreeSpec with PropertyChecks with Matchers {
55
56
t.wellConstructed shouldBe " true"
56
57
}
57
58
58
- for (k <- size + 1 to 2 * size ) {
59
+ for (k <- insertions + 1 to 2 * insertions ) {
59
60
t.insert( k, string ) shouldBe false
60
61
t.wellConstructed shouldBe " true"
61
62
}
62
63
63
- for (k <- size / 2 + 1 to size ) {
64
+ for (k <- insertions / 2 + 1 to insertions ) {
64
65
t.search( k ) match {
65
66
case None => fail
66
67
case Some ( v ) => set -= v
@@ -70,15 +71,14 @@ class FileSpecificTests extends FreeSpec with PropertyChecks with Matchers {
70
71
t.wellConstructed shouldBe " true"
71
72
}
72
73
73
- assert( t.keysIterator.toList == (size + 1 to 2 * size ) )
74
+ assert( t.keysIterator.toList == (insertions + 1 to 2 * insertions ) )
74
75
assert( t.valuesIterator.toSet == set )
75
76
}
76
77
77
78
" inserting/deleting/retrieving maps" in {
78
79
val t = new FileBPlusTree [Int , collection.Map [Int , String ]]( newfile, 3 )
79
80
val sset = new HashSet [String ]
80
81
val mset = new HashSet [collection.Map [Int , String ]]
81
- val size = 50
82
82
val len = 500
83
83
84
84
def map : collection.Map [Int , String ] = {
@@ -94,12 +94,12 @@ class FileSpecificTests extends FreeSpec with PropertyChecks with Matchers {
94
94
}
95
95
}
96
96
97
- for (k <- 1 to size ) {
97
+ for (k <- 1 to insertions ) {
98
98
t.insert( k, map ) shouldBe false
99
99
t.wellConstructed shouldBe " true"
100
100
}
101
101
102
- for (k <- 1 to size / 2 ) {
102
+ for (k <- 1 to insertions / 2 ) {
103
103
t.search( k ) match {
104
104
case None => fail
105
105
case Some ( v ) =>
@@ -113,12 +113,12 @@ class FileSpecificTests extends FreeSpec with PropertyChecks with Matchers {
113
113
t.wellConstructed shouldBe " true"
114
114
}
115
115
116
- for (k <- size + 1 to 2 * size ) {
116
+ for (k <- insertions + 1 to 2 * insertions ) {
117
117
t.insert( k, map ) shouldBe false
118
118
t.wellConstructed shouldBe " true"
119
119
}
120
120
121
- for (k <- size / 2 + 1 to size ) {
121
+ for (k <- insertions / 2 + 1 to insertions ) {
122
122
t.search( k ) match {
123
123
case None => fail
124
124
case Some ( v ) =>
@@ -132,15 +132,14 @@ class FileSpecificTests extends FreeSpec with PropertyChecks with Matchers {
132
132
t.wellConstructed shouldBe " true"
133
133
}
134
134
135
- assert( t.keysIterator.toList == (size + 1 to 2 * size ) )
135
+ assert( t.keysIterator.toList == (insertions + 1 to 2 * insertions ) )
136
136
assert( t.valuesIterator.toSet == mset )
137
137
}
138
138
139
139
" inserting/deleting/retrieving arrays" in {
140
140
val t = new FileBPlusTree [Int , collection.Seq [String ]]( newfile, 3 )
141
141
val sset = new HashSet [String ]
142
142
val lset = new HashSet [collection.Seq [String ]]
143
- val size = 50
144
143
val len = 500
145
144
146
145
def seq : collection.Seq [String ] = {
@@ -156,12 +155,12 @@ class FileSpecificTests extends FreeSpec with PropertyChecks with Matchers {
156
155
}
157
156
}
158
157
159
- for (k <- 1 to size ) {
158
+ for (k <- 1 to insertions ) {
160
159
t.insert( k, seq ) shouldBe false
161
160
t.wellConstructed shouldBe " true"
162
161
}
163
162
164
- for (k <- 1 to size / 2 ) {
163
+ for (k <- 1 to insertions / 2 ) {
165
164
t.search( k ) match {
166
165
case None => fail
167
166
case Some ( v ) =>
@@ -173,12 +172,12 @@ class FileSpecificTests extends FreeSpec with PropertyChecks with Matchers {
173
172
t.wellConstructed shouldBe " true"
174
173
}
175
174
176
- for (k <- size + 1 to 2 * size ) {
175
+ for (k <- insertions + 1 to 2 * insertions ) {
177
176
t.insert( k, seq ) shouldBe false
178
177
t.wellConstructed shouldBe " true"
179
178
}
180
179
181
- for (k <- size / 2 + 1 to size ) {
180
+ for (k <- insertions / 2 + 1 to insertions ) {
182
181
t.search( k ) match {
183
182
case None => fail
184
183
case Some ( v ) =>
@@ -192,7 +191,7 @@ class FileSpecificTests extends FreeSpec with PropertyChecks with Matchers {
192
191
t.wellConstructed shouldBe " true"
193
192
}
194
193
195
- assert( t.keysIterator.toList == (size + 1 to 2 * size ) )
194
+ assert( t.keysIterator.toList == (insertions + 1 to 2 * insertions ) )
196
195
assert( t.valuesIterator.toSet == lset )
197
196
}
198
197
0 commit comments