MCPcopy Create free account
hub / github.com/apache/arrow / VerifyStringAndNumber_Single

Function VerifyStringAndNumber_Single

cpp/src/arrow/acero/tpch_node_test.cc:98–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98void VerifyStringAndNumber_Single(std::string_view row, std::string_view prefix,
99 const int64_t i, const int32_t* nums,
100 bool verify_padding) {
101 ASSERT_TRUE(row.starts_with(prefix)) << row << ", prefix=" << prefix << ", i=" << i;
102 const char* num_str = row.data() + prefix.size();
103 const char* num_str_end = row.data() + row.size();
104 int64_t num = 0;
105 // Parse the number out; note that it can be padded with NUL chars at the end
106 for (; num_str < num_str_end && *num_str; num_str++) {
107 num *= 10;
108 ASSERT_TRUE(std::isdigit(*num_str)) << row << ", prefix=" << prefix << ", i=" << i;
109 num += *num_str - '0';
110 }
111 // If nums is not null, ensure it matches the parsed number
112 if (nums) {
113 ASSERT_EQ(num, nums[i]);
114 }
115 // TPC-H requires only ever requires padding up to 9 digits, so we ensure that
116 // the total length of the string was at least 9 (could be more for bigger numbers).
117 if (verify_padding) {
118 const auto num_chars = num_str - (row.data() + prefix.size());
119 ASSERT_GE(num_chars, 9);
120 }
121}
122
123// Verifies that each row is the string "prefix" followed by a number. If numbers is not
124// EMPTY, it also checks that the number following the prefix is equal to the

Callers 2

Calls 2

dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected