Skip to content

Commit

Permalink
add test for increment_version()
Browse files Browse the repository at this point in the history
  • Loading branch information
ban-nobuhiro committed Jun 19, 2024
1 parent 332a4a6 commit 190694c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/version_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <xmmintrin.h>

#include <algorithm>
#include <future>

#include "gtest/gtest.h"
Expand Down Expand Up @@ -116,4 +117,35 @@ TEST_F(vt, vsplit) { // NOLINT
fin();
}

TEST_F(vt, increment_version) { // NOLINT
init();
create_storage(test_storage_name);
tree_instance* ti{};
find_storage(test_storage_name, &ti);
std::string k{"k"};
std::string v{"v"};

// setup any tree structure
Token token{};
while (status::OK != enter(token)) { _mm_pause(); }
ASSERT_EQ(status::OK, put(token, test_storage_name, "0", v.data(), v.size()));
ASSERT_EQ(status::OK, put(token, test_storage_name, k, v.data(), v.size()));
leave(token);

std::vector<std::pair<node_version64_body, node_version64*>> nvp{};
std::vector<std::tuple<std::string, char*, std::size_t>> scan_res{};
auto changed = [&nvp]{
return std::any_of(nvp.begin(), nvp.end(), [](auto p){
return p.first.get_vinsert_delete() != p.second->get_vinsert_delete();
}); };
ASSERT_EQ(status::OK,
scan(test_storage_name, k, scan_endpoint::INCLUSIVE, k,
scan_endpoint::INCLUSIVE, scan_res, &nvp));
ASSERT_NE(nvp.size(), 0);
ASSERT_FALSE(changed()); // no change
ASSERT_EQ(status::OK, increment_version(test_storage_name, k));
ASSERT_TRUE(changed()); // changed
fin();
}

} // namespace yakushima::testing

0 comments on commit 190694c

Please sign in to comment.