Verifies that each row is a V-string, which is defined in the spec to be a string of random length between min_length and max_length, that is composed of alphanumeric characters, commas, or spaces.
| 169 | // a string of random length between min_length and max_length, that is composed |
| 170 | // of alphanumeric characters, commas, or spaces. |
| 171 | void VerifyVString(const Datum& d, int min_length, int max_length) { |
| 172 | int64_t length = d.length(); |
| 173 | const int32_t* off = reinterpret_cast<const int32_t*>(d.array()->buffers[1]->data()); |
| 174 | const char* str = reinterpret_cast<const char*>(d.array()->buffers[2]->data()); |
| 175 | for (int64_t i = 0; i < length; i++) { |
| 176 | int32_t start = off[i]; |
| 177 | int32_t end = off[i + 1]; |
| 178 | int32_t str_len = end - start; |
| 179 | ASSERT_LE(str_len, max_length); |
| 180 | ASSERT_GE(str_len, min_length); |
| 181 | for (int32_t i = start; i < end; i++) { |
| 182 | bool is_valid = |
| 183 | std::isdigit(str[i]) || std::isalpha(str[i]) || str[i] == ',' || str[i] == ' '; |
| 184 | ASSERT_TRUE(is_valid) << "Character " << str[i] |
| 185 | << " is not a digit, a letter, a comma, or a space"; |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | // Verifies that each 32-bit element modulo "mod" is between min and max. |
| 191 | void VerifyModuloBetween(const Datum& d, int32_t min, int32_t max, int32_t mod) { |
no test coverage detected