| Index: tools/gn/functions_unittest.cc
|
| diff --git a/tools/gn/functions_unittest.cc b/tools/gn/functions_unittest.cc
|
| index 22670710704c6969255185ae5b3c34ca2b910a50..c6681bf5909b78362e2c0a80c77abfbe5ef956e6 100644
|
| --- a/tools/gn/functions_unittest.cc
|
| +++ b/tools/gn/functions_unittest.cc
|
| @@ -90,3 +90,39 @@ TEST(Functions, FunctionsWithBlock) {
|
| result = defined_with_scope.parsed()->Execute(setup.scope(), &err);
|
| EXPECT_TRUE(err.has_error());
|
| }
|
| +
|
| +TEST(Functions, SplitList) {
|
| + TestWithScope setup;
|
| +
|
| + TestParseInput input(
|
| + // Empty input with varying result items.
|
| + "out1 = split_list([], 1)\n"
|
| + "out2 = split_list([], 3)\n"
|
| + "print(\"empty = $out1 $out2\")\n"
|
| +
|
| + // One item input.
|
| + "out3 = split_list([1], 1)\n"
|
| + "out4 = split_list([1], 2)\n"
|
| + "print(\"one = $out3 $out4\")\n"
|
| +
|
| + // Multiple items.
|
| + "out5 = split_list([1, 2, 3, 4, 5, 6, 7, 8, 9], 2)\n"
|
| + "print(\"many = $out5\")\n"
|
| +
|
| + // Rounding.
|
| + "out6 = split_list([1, 2, 3, 4, 5, 6], 4)\n"
|
| + "print(\"rounding = $out6\")\n"
|
| + );
|
| + ASSERT_FALSE(input.has_error());
|
| +
|
| + Err err;
|
| + input.parsed()->Execute(setup.scope(), &err);
|
| + ASSERT_FALSE(err.has_error()) << err.message();
|
| +
|
| + EXPECT_EQ(
|
| + "empty = [[]] [[], [], []]\n"
|
| + "one = [[1]] [[1], []]\n"
|
| + "many = [[1, 2, 3, 4, 5], [6, 7, 8, 9]]\n"
|
| + "rounding = [[1, 2], [3, 4], [5], [6]]\n",
|
| + setup.print_output());
|
| +}
|
|
|