Skip to content

Commit

Permalink
Add PrimitiveTypeCustomArrayElementDelimiter test.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingurney committed Oct 2, 2023
1 parent d08fe8b commit 883a346
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions cpp/src/arrow/pretty_print_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,33 @@ TEST_F(TestPrettyPrint, PrimitiveTypeNoNewlines) {
CheckPrimitive<Int32Type, int32_t>(options, is_valid, values, expected, false);
}

TEST_F(TestPrettyPrint, PrimitiveTypeCustomArrayElementDelimiter) {
PrettyPrintOptions options{};
// Display array contents on one line.
options.skip_new_lines = true;
// Display maximum of 3 elements at the beginning and at the end of the array
options.window = 3;
// Use a custom array element delimiter of " | ",
// rather than the default delimiter (i.e. ",").
options.array_element_delimiter = " | ";

// Short array without ellipsis
{
std::vector<bool> is_valid = {true, true, false, true, false};
std::vector<int32_t> values = {1, 2, 3, 4, 5};
const char* expected = "[1 | 2 | null | 4 | null]";
CheckPrimitive<Int32Type, int32_t>(options, is_valid, values, expected, false);
}

// Longer array with ellipsis
{
std::vector<bool> is_valid = {true, false, true, true, false, true, false, true, true};
std::vector<int32_t> values = {1, 2, 3, 4, 5, 6, 7, 8, 9};
const char* expected = "[1 | null | 3 | ... | null | 8 | 9]";
CheckPrimitive<Int32Type, int32_t>(options, is_valid, values, expected, false);
}
}

TEST_F(TestPrettyPrint, Int8) {
static const char* expected = R"expected([
0,
Expand Down

0 comments on commit 883a346

Please sign in to comment.