| 37 | } |
| 38 | |
| 39 | void TestReferencing() |
| 40 | { |
| 41 | /* Thrash the Sequence through repeated appends, deletes, etc. |
| 42 | * Then delete the sequence and ensure that all blocks have |
| 43 | * been unreferenced to the point of deletion -- the dirmanager |
| 44 | * should be empty. */ |
| 45 | |
| 46 | std::cout << "\tafter thrashing the sequence and deleting it, all block files should have been deleted..." << std::flush; |
| 47 | |
| 48 | int appendBufLen = (int)(mSequence->GetMaxBlockSize() * 1.4); |
| 49 | samplePtr appendBuf = NewSamples(appendBufLen, floatSample); |
| 50 | int i; |
| 51 | |
| 52 | for(i = 0; i < 10; i++) |
| 53 | mSequence->Append(appendBuf, floatSample, appendBufLen); |
| 54 | |
| 55 | for(i = 0; i < 10; i++) |
| 56 | { |
| 57 | Sequence *tmpSequence; |
| 58 | |
| 59 | /* append */ |
| 60 | |
| 61 | mSequence->Append(appendBuf, floatSample, appendBufLen); |
| 62 | |
| 63 | /* copy/paste */ |
| 64 | |
| 65 | int s0 = rand()%mSequence->GetNumSamples(); |
| 66 | int len = rand()%(mSequence->GetNumSamples() - s0); |
| 67 | mSequence->Copy(s0, s0+len, &tmpSequence); |
| 68 | |
| 69 | int dest = rand()%mSequence->GetNumSamples(); |
| 70 | mSequence->Paste(dest, tmpSequence); |
| 71 | delete tmpSequence; |
| 72 | |
| 73 | /* delete */ |
| 74 | |
| 75 | int del = rand()%mSequence->GetNumSamples(); |
| 76 | int dellen = rand()%((mSequence->GetNumSamples()-del)/2); |
| 77 | |
| 78 | mSequence->Delete(del, dellen); |
| 79 | } |
| 80 | |
| 81 | delete mSequence; |
| 82 | mSequence = NULL; |
| 83 | |
| 84 | assert(mDirManager->blockFileHash->GetCount() == 0); |
| 85 | |
| 86 | std::cout << "ok\n"; |
| 87 | } |
| 88 | |
| 89 | void TestSetGarbageInput() |
| 90 | { |
no test coverage detected