Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/actions/build-tntcxx/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ runs:
-DTNTCXX_ENABLE_SANITIZERS=${{ inputs.enable-sanitizers }} \
-DCMAKE_CXX_STANDARD=${{ inputs.cxx-standard }} \
-DCMAKE_C_COMPILER=${{ inputs.c-compiler }} \
-DCMAKE_CXX_COMPILER=${{ inputs.cxx-compiler }}
-DCMAKE_CXX_COMPILER=${{ inputs.cxx-compiler }} \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
make -j
shell: bash
4 changes: 2 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
fail-fast: false
matrix:
runs-on:
- ubuntu-20.04
- ubuntu-22.04
- ubuntu-24.04
- macos-13
- macos-14
- macos-15
Expand All @@ -35,8 +35,8 @@ jobs:
fail-fast: false
matrix:
runs-on:
- ubuntu-20.04
- ubuntu-22.04
- ubuntu-24.04
- macos-13
- macos-14
- macos-15
Expand Down
2 changes: 1 addition & 1 deletion src/Buffer/Buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ std::string
dump(Buffer<N, allocator> &buffer)
{
size_t vec_len = 0;
size_t IOVEC_MAX = 1024;
constexpr size_t IOVEC_MAX = 1024;
size_t block_cnt = 0;
struct iovec vec[IOVEC_MAX];
std::string output;
Expand Down
4 changes: 2 additions & 2 deletions src/Client/ResponseReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ struct Data {

/** Unpacks tuples to passed container. */
template<class T>
bool decode(T& tuples)
bool decode(T&& tuples)
{
it_t itr = iters.first;
bool ok = mpp::decode(itr, tuples);
bool ok = mpp::decode(itr, std::forward<T>(tuples));
assert(!ok || itr == iters.second);
return ok;
}
Expand Down
30 changes: 24 additions & 6 deletions test/BufferUnitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ template<size_t N>
static void
eraseBuffer(tnt::Buffer<N> &buffer)
{
int IOVEC_MAX = 1024;
constexpr int IOVEC_MAX = 1024;
struct iovec vec[IOVEC_MAX];
do {
size_t vec_size = buffer.getIOV(buffer.begin(), vec, IOVEC_MAX);
Expand All @@ -89,7 +89,7 @@ static void
dumpBuffer(tnt::Buffer<N> &buffer, std::string &output)
{
size_t vec_len = 0;
int IOVEC_MAX = 1024;
constexpr int IOVEC_MAX = 1024;
size_t block_cnt = 0;
struct iovec vec[IOVEC_MAX];
for (auto itr = buffer.begin(); itr != buffer.end(); itr += vec_len) {
Expand Down Expand Up @@ -575,7 +575,7 @@ buffer_out()
fail_if(buf.debugSelfCheck());
save.unlink();
do {
int IOVEC_MAX = 1024;
constexpr int IOVEC_MAX = 1024;
struct iovec vec[IOVEC_MAX];
size_t vec_size = buf.getIOV(buf.begin(), vec, IOVEC_MAX);
buf.dropFront(vec_size);
Expand All @@ -592,7 +592,7 @@ buffer_iterator_get()
{
TEST_INIT(1, N);
tnt::Buffer<N> buf;
size_t DATA_SIZE = SAMPLES_CNT * 10;
constexpr size_t DATA_SIZE = SAMPLES_CNT * 10;
fillBuffer(buf, DATA_SIZE);
buf.write(end_marker);
fail_if(buf.debugSelfCheck());
Expand All @@ -613,6 +613,24 @@ auto itr_at(BUF &buf, size_t pos)
return itr;
}

/** A helper to move buffer to itself - disables warning on GCC compiler. */
template <class BUF>
static inline void
buffer_move_to_self(BUF &buf)
{
/* Self-move warning was introduced in GCC 13. */
#if __GNUC__ >= 13
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wself-move"
#endif

buf = std::move(buf);

#if __GNUC__ >= 13
#pragma GCC diagnostic pop
#endif
}

/**
* Test move constructor and assignment.
*/
Expand All @@ -626,7 +644,7 @@ buffer_move()
tnt::Buffer<N> buf1;
fillBuffer(buf1, S);
/* It is ok to move to itself. */
buf1 = std::move(buf1);
buffer_move_to_self(buf1);

/* Create three iterators pointing to different parts. */
auto itr0 = buf1.begin();
Expand Down Expand Up @@ -655,7 +673,7 @@ buffer_move()
fail_unless(!buf1.has(buf1.begin(), S + ins_cnt + 1));

/* It is ok to move to itself. */
buf1 = std::move(buf1);
buffer_move_to_self(buf1);
fail_unless(itr0 == buf1.begin());
fail_unless(itr1 == itr_at(buf1, 1 + ins_cnt));
fail_unless(itr2 == itr_at(buf1, S / 2 + ins_cnt));
Expand Down
11 changes: 11 additions & 0 deletions test/ClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,17 @@ response_decoding(Connector<BUFFER, NetProvider> &client)
fail_if(response->body.data->decode(arr_of_str));
/* We should successfully decode data after all. */
fail_unless(response->body.data->decode(arr_of_num));
fail_unless(std::get<0>(arr_of_num) == 666);

TEST_CASE("decode data to rvalue object");
num = 0;
fail_unless(response->body.data->decode(std::forward_as_tuple(num)));
fail_unless(num == 666);

TEST_CASE("decode data to object with an mpp tag");
std::get<0>(arr_of_num) = 0;
fail_unless(response->body.data->decode(mpp::as_arr(arr_of_num)));
fail_unless(std::get<0>(arr_of_num) == 666);

client.close(conn);
}
Expand Down
Loading