MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / validate

Method validate

test/copy/multi_copy_test.cpp:60–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58 }
59
60 void validate(bool isSerial = false) const {
61 std::unique_ptr<main::QueryResult> countResult;
62 if (isSerial) {
63 countResult = conn->query("MATCH (t:TestSerial) RETURN COUNT(*)");
64 } else {
65 countResult = conn->query("MATCH (t:Test) RETURN COUNT(*)");
66 }
67 ASSERT_TRUE(countResult->isSuccess()) << countResult->toString();
68 ASSERT_EQ(countResult->getNumTuples(), 1);
69 ASSERT_EQ(countResult->getNext()->getValue(0)->getValue<int64_t>(), totalTuples);
70
71 std::random_device dev;
72 std::mt19937 rng(dev());
73 std::uniform_int_distribution<std::mt19937::result_type> dist(0, totalTuples - 1);
74 // Sample and check up to 1000 random elements in the range
75 if (isSerial) {
76 for (size_t i = 0; i < std::min(static_cast<size_t>(1000), totalTuples); i++) {
77 auto index = dist(rng);
78 auto result = conn->query(
79 std::format("MATCH (t:TestSerial) WHERE t.id = {} RETURN t.id", index));
80 ASSERT_TRUE(result->isSuccess()) << result->toString();
81 ASSERT_EQ(result->getNumTuples(), 1) << "ID " << index << " is missing";
82 }
83 } else {
84 for (size_t i = 0; i < std::min(static_cast<size_t>(1000), totalTuples); i++) {
85 auto index = dist(rng);
86 auto result =
87 conn->query(std::format("MATCH (t:Test) WHERE t.id = {} RETURN t.id", index));
88 ASSERT_TRUE(result->isSuccess()) << result->toString();
89 ASSERT_EQ(result->getNumTuples(), 1) << "ID " << index << " is missing";
90 ASSERT_EQ(result->getNext()->getValue(0)->getValue<int32_t>(), index);
91 }
92 }
93 }
94
95private:
96 size_t totalTuples = 0;

Callers

nothing calls this directly

Calls 6

queryMethod · 0.45
isSuccessMethod · 0.45
toStringMethod · 0.45
getNumTuplesMethod · 0.45
getValueMethod · 0.45
getNextMethod · 0.45

Tested by

no test coverage detected