@@ -12,20 +12,22 @@ import (
12
12
13
13
const casef string = "case: %s"
14
14
15
- //TestEnqueue attempt to unit test the enqueue function, in general it confirms the
15
+ // TestEnqueue attempt to unit test the enqueue function, in general it confirms the
16
16
// behavior, that for an infinite queue, no matter how much data you put into the
17
17
// queue, the queue will never overflow and there will be no data loss. This test
18
18
// also assumes that the "size" of the queue won't affect the behavior of enqueue
19
19
// This test has some "configuration" items that can be "tweaked" for your specific
20
20
// queue implementation:
21
- // - rate: this is the rate at which the test will attempt to enqueue/dequeue
22
- // - timeout: this is when the test will "give up"
21
+ // - rate: this is the rate at which the test will attempt to enqueue/dequeue
22
+ // - timeout: this is when the test will "give up"
23
+ //
23
24
// Some assumptions this test does make:
24
- // - your queue can handle valid data, as a plus the example data type supports the
25
- // BinaryMarshaller
25
+ // - your queue can handle valid data, as a plus the example data type supports the
26
+ // BinaryMarshaller
27
+ //
26
28
// Some assumptions this test won't make:
27
- // - order is maintained
28
- // - the "size" of the queue affects the behavior of enqueue
29
+ // - order is maintained
30
+ // - the "size" of the queue affects the behavior of enqueue
29
31
func TestEnqueue (t * testing.T , rate , timeout time.Duration , newQueue func () interface {
30
32
goqueue.Owner
31
33
goqueue.Enqueuer
@@ -86,19 +88,21 @@ func TestEnqueue(t *testing.T, rate, timeout time.Duration, newQueue func() inte
86
88
}
87
89
}
88
90
89
- //TestEnqueueMultiple will attempt to unit test the EnqueueMultiple function;
91
+ // TestEnqueueMultiple will attempt to unit test the EnqueueMultiple function;
90
92
// for an infinite queue, this function will never overflow nor will it return
91
93
// items that weren't able to be enqueued.
92
94
// This test has some "configuration" items that can be "tweaked" for your specific
93
95
// queue implementation:
94
- // - rate: this is the rate at which the test will attempt to enqueue/dequeue
95
- // - timeout: this is when the test will "give up"
96
+ // - rate: this is the rate at which the test will attempt to enqueue/dequeue
97
+ // - timeout: this is when the test will "give up"
98
+ //
96
99
// Some assumptions this test does make:
97
- // - your queue can handle valid data, as a plus the example data type supports the
98
- // BinaryMarshaller
100
+ // - your queue can handle valid data, as a plus the example data type supports the
101
+ // BinaryMarshaller
102
+ //
99
103
// Some assumptions this test won't make:
100
- // - order is maintained
101
- // - the "size" of the queue affects the behavior of enqueue
104
+ // - order is maintained
105
+ // - the "size" of the queue affects the behavior of enqueue
102
106
func TestEnqueueMultiple (t * testing.T , rate , timeout time.Duration , newQueue func () interface {
103
107
goqueue.Owner
104
108
goqueue.Enqueuer
@@ -162,20 +166,22 @@ func TestEnqueueMultiple(t *testing.T, rate, timeout time.Duration, newQueue fun
162
166
}
163
167
}
164
168
165
- //TestEnqueueInFront will validate that if there is data in the queue and you attempt to
169
+ // TestEnqueueInFront will validate that if there is data in the queue and you attempt to
166
170
// enqueue in front, that special "data" will go to the front, while if the queue is empty
167
171
// that data will just be "in" the queue (a regular queue if the queue is empty).
168
172
// This test has some "configuration" items that can be "tweaked" for your specific
169
173
// queue implementation:
170
- // - rate: this is the rate at which the test will attempt to enqueue/dequeue
171
- // - timeout: this is when the test will "give up"
174
+ // - rate: this is the rate at which the test will attempt to enqueue/dequeue
175
+ // - timeout: this is when the test will "give up"
176
+ //
172
177
// Some assumptions this test does make:
173
- // - your queue can handle valid data, as a plus the example data type supports the
174
- // BinaryMarshaller
175
- // - your queue maintains order
176
- // - it's safe to use a single instance of your queue for each test case
178
+ // - your queue can handle valid data, as a plus the example data type supports the
179
+ // BinaryMarshaller
180
+ // - your queue maintains order
181
+ // - it's safe to use a single instance of your queue for each test case
182
+ //
177
183
// Some assumptions this test won't make:
178
- // - the "size" of the queue affects the behavior of enqueue
184
+ // - the "size" of the queue affects the behavior of enqueue
179
185
func TestEnqueueInFront (t * testing.T , rate , timeout time.Duration , newQueue func () interface {
180
186
goqueue.Owner
181
187
goqueue.Enqueuer
@@ -224,8 +230,7 @@ func TestEnqueueInFront(t *testing.T, rate, timeout time.Duration, newQueue func
224
230
item , underflow := goqueue .MustDequeue (q , ctx .Done (), rate )
225
231
cancel ()
226
232
assert .False (t , underflow )
227
- assert .IsType (t , & goqueue.Example {}, item , casef , cDesc )
228
- example , _ := item .(* goqueue.Example )
233
+ example := goqueue .ExampleConvertSingle (item )
229
234
assert .Equal (t , c .iInFrontValue , example , casef , cDesc )
230
235
231
236
//flush the queue to empty it
@@ -238,7 +243,7 @@ func TestEnqueueInFront(t *testing.T, rate, timeout time.Duration, newQueue func
238
243
}
239
244
}
240
245
241
- //TestEnqueueEvent will confirm that the signal channels function correctly when data is enqueued,
246
+ // TestEnqueueEvent will confirm that the signal channels function correctly when data is enqueued,
242
247
// this function for an infinite queue is slightly different because it can't be lossless, there's
243
248
// no way to properly implement a buffered channel with an infinite queue
244
249
// Some assumptions this test does make:
0 commit comments