コード例 #1
0
TEST(HashTableBufferManager, GetBuffersDump) {
    HashTableBufferManager manager;
    manager.initBuffers(3, 5);
    const QList<SignalValueVector> &data = {
        {{1.0, 0}, {1.5, 0}, {2.5, 1}},
        {{2.0, 0}, {2.5, 0}, {0.5, 1}},
        {{3.0, 0}, {1.5, 0}, {2.4, 1}},
        {{4.0, 0}, {2.5, 0}, {2.2, 0}},
        {{5.0, 0}, {1.5, 0}, {2.1, 1}},
    };

    manager.pushSignalValues(data.at(0), 0);
    manager.pushSignalValues(data.at(1), 1);
    manager.pushSignalValues(data.at(2), 2);
    manager.pushSignalValues(data.at(3), 3);
    manager.pushSignalValues(data.at(4), 4);

    const QList<SignalValueVector> &transposedData = {
        {{1.0, 0}, {2.0, 0}, {3.0, 0}, {4.0, 0}, {5.0, 0}},
        {{1.5, 0}, {2.5, 0}, {1.5, 0}, {2.5, 0}, {1.5, 0}},
        {{2.5, 1}, {0.5, 1}, {2.4, 1} ,{2.2, 0} ,{2.1, 1}}
    };
    Buffers buffers;
    buffers.insert(0, transposedData.at(0));
    buffers.insert(2, transposedData.at(1));
    buffers.insert(4, transposedData.at(2));

    EXPECT_EQ(buffers, manager.getBuffers());
}
コード例 #2
0
ファイル: request.cpp プロジェクト: jhs67/httplib
	size_t bodyBuffers(bool chunked, list<string> &chunkLines, const iovec* vec, int c, Buffers& buffers) {
		size_t rsize = 0;
		for (int i = 0; i < c; ++i)
			rsize += vec[i].iov_len;

		if (rsize != 0) {
			if (chunked) {
				chunkLines.push_back(hexSize(rsize));
				buffers.push_back(toBuffer(chunkLines.back()));
				buffers.push_back(blanklineBuffer());
				buffers.insert(buffers.end(), vec, vec + c);
				buffers.push_back(blanklineBuffer());
			}
			else {
				buffers.insert(buffers.end(), vec, vec + c);
			}
		}

		return rsize;
	}