MCPcopy Create free account
hub / github.com/audacity/audacity / TestReferencing

Method TestReferencing

tests/SequenceTest.cpp:39–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 1

mainFunction · 0.80

Calls 7

GetMaxBlockSizeMethod · 0.45
AppendMethod · 0.45
GetNumSamplesMethod · 0.45
CopyMethod · 0.45
PasteMethod · 0.45
DeleteMethod · 0.45
GetCountMethod · 0.45

Tested by

no test coverage detected