Changeset - ec2bd041e1de
[Not reviewed]
longmem
0 2 0
Hasan Yavuz Ă–ZDERYA - 8 years ago 2017-08-12 12:58:41
hy@ozderya.net
added clear method
2 files changed with 19 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/chunkedbuffer.cpp
Show inline comments
 
@@ -55,12 +55,28 @@ void ChunkedBuffer::addSamples(double* s
 
        i += c;
 
    }
 

	
 
    _size += size;
 
}
 

	
 
void ChunkedBuffer::clear()
 
{
 
    // delete all chunks
 
    for (auto chunk : chunks)
 
    {
 
        delete chunk;
 
    }
 
    chunks.clear();
 

	
 
    numChunks = 0;
 
    _size = 0;
 

	
 
    // create first chunk
 
    addNewChunk();
 
}
 

	
 
DataChunk* ChunkedBuffer::addNewChunk()
 
{
 
    auto chunk = new DataChunk(_size, CHUNK_SIZE);
 
    chunks.append(chunk);
 
    return chunk;
 
}
tests/test.cpp
Show inline comments
 
@@ -113,15 +113,15 @@ TEST_CASE("ChunkedBuffer adding data and
 
    // add more data to make it 4 chunks
 
    double samples3[CHUNK_SIZE*3-N] = {0};
 
    b.addSamples(samples3, CHUNK_SIZE*3-N);
 
    REQUIRE(b.size() == CHUNK_SIZE*4);
 
    REQUIRE(b.boundingRect() == QRectF(0,10,CHUNK_SIZE*4,10));
 

	
 
    // TODO: clear
 
    // b.clear();
 
    // REQUIRE(b.size() == 0);
 
    // clear
 
    b.clear();
 
    REQUIRE(b.size() == 0);
 
}
 

	
 
TEST_CASE("ChunkedBuffer accessing data", "[memory]")
 
{
 
    ChunkedBuffer b;
 

	
0 comments (0 inline, 0 general)