Same as above but for fixed width columns.
| 269 | |
| 270 | // Same as above but for fixed width columns. |
| 271 | void VerifyCorrectNumberOfWords_FixedWidth(const Datum& d, int num_words, |
| 272 | int byte_width) { |
| 273 | int expected_num_spaces = num_words - 1; |
| 274 | int64_t length = d.length(); |
| 275 | const char* str = reinterpret_cast<const char*>(d.array()->buffers[1]->data()); |
| 276 | |
| 277 | for (int64_t i = 0; i < length; i++) { |
| 278 | int actual_num_spaces = 0; |
| 279 | const char* row = str + i * byte_width; |
| 280 | bool is_only_alphas_or_spaces = true; |
| 281 | for (int32_t j = 0; j < byte_width && row[j]; j++) { |
| 282 | bool is_space = row[j] == ' '; |
| 283 | actual_num_spaces += is_space; |
| 284 | is_only_alphas_or_spaces &= (is_space || std::isalpha(row[j])); |
| 285 | } |
| 286 | ASSERT_TRUE(is_only_alphas_or_spaces) |
| 287 | << "Words must be composed only of letters, got " << row; |
| 288 | ASSERT_EQ(actual_num_spaces, expected_num_spaces) |
| 289 | << "Wrong number of spaces in " << row; |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | // Verifies that each row of the single-byte-wide column is one of the possibilities. |
| 294 | void VerifyOneOf(const Datum& d, const std::unordered_set<char>& possibilities) { |
no test coverage detected