(t *testing.T)
| 173 | } |
| 174 | |
| 175 | func TestPriorityQueueDequeueByPriority(t *testing.T) { |
| 176 | file := fmt.Sprintf("test_db_%d", time.Now().UnixNano()) |
| 177 | pq, err := OpenPriorityQueue(file, ASC) |
| 178 | if err != nil { |
| 179 | t.Error(err) |
| 180 | } |
| 181 | defer pq.Drop() |
| 182 | |
| 183 | for p := 0; p <= 4; p++ { |
| 184 | for i := 1; i <= 10; i++ { |
| 185 | if _, err = pq.EnqueueString(uint8(p), fmt.Sprintf("value for item %d", i)); err != nil { |
| 186 | t.Error(err) |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | if pq.Length() != 50 { |
| 192 | t.Errorf("Expected queue length of 50, got %d", pq.Length()) |
| 193 | } |
| 194 | |
| 195 | deqItem, err := pq.DequeueByPriority(3) |
| 196 | if err != nil { |
| 197 | t.Error(err) |
| 198 | } |
| 199 | |
| 200 | if pq.Length() != 49 { |
| 201 | t.Errorf("Expected queue length of 49, got %d", pq.Length()) |
| 202 | } |
| 203 | |
| 204 | compStr := "value for item 1" |
| 205 | |
| 206 | if deqItem.Priority != 3 { |
| 207 | t.Errorf("Expected priority level to be 1, got %d", deqItem.Priority) |
| 208 | } |
| 209 | |
| 210 | if deqItem.ToString() != compStr { |
| 211 | t.Errorf("Expected string to be '%s', got '%s'", compStr, deqItem.ToString()) |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | func TestPriorityQueueEncodeDecodePointerJSON(t *testing.T) { |
| 216 | file := fmt.Sprintf("test_db_%d", time.Now().UnixNano()) |
nothing calls this directly
no test coverage detected