string for debugging - make a copy and pop the items out in order
(t *testing.T)
| 28 | |
| 29 | // string for debugging - make a copy and pop the items out in order |
| 30 | func (wb *WriteBack) string(t *testing.T) string { |
| 31 | wb.mu.Lock() |
| 32 | defer wb.mu.Unlock() |
| 33 | ws := wb.items |
| 34 | |
| 35 | // check indexes OK first |
| 36 | for i := range ws { |
| 37 | assert.Equal(t, i, ws[i].index, ws[i].name) |
| 38 | } |
| 39 | wsCopy := make(writeBackItems, len(ws)) |
| 40 | // deep copy the elements |
| 41 | for i := range wsCopy { |
| 42 | item := *ws[i] |
| 43 | wsCopy[i] = &item |
| 44 | } |
| 45 | // print them |
| 46 | var out []string |
| 47 | for wsCopy.Len() > 0 { |
| 48 | out = append(out, heap.Pop(&wsCopy).(*writeBackItem).name) |
| 49 | } |
| 50 | return strings.Join(out, ",") |
| 51 | } |
| 52 | |
| 53 | func TestWriteBackItems(t *testing.T) { |
| 54 | // Test the items heap behaves properly |
no test coverage detected