ArianaVillegas commented on code in PR #12625:
URL: https://github.com/apache/arrow/pull/12625#discussion_r863937762


##########
cpp/src/arrow/filesystem/filesystem_test.cc:
##########
@@ -265,6 +265,24 @@ TEST(PathUtil, ToSlashes) {
 #endif
 }
 
+TEST(PathUtil, Globber) {
+  Globber localfs_linux("/f?o/bar/a?/1*.txt");
+  ASSERT_TRUE(localfs_linux.Matches("/foo/bar/a1/1.txt"));
+  ASSERT_TRUE(localfs_linux.Matches("/f#o/bar/ab/1000.txt"));
+
+  Globber localfs_windows("C:/f?o/bar/a?/1*.txt");
+  ASSERT_TRUE(localfs_windows.Matches("C:/f_o/bar/ac/1000.txt"));
+
+  Globber remotefs("remote://my|bucket(#?)/foo{*}/[?]bar~/b&z/a: *-c.txt");
+  ASSERT_TRUE(remotefs.Matches("remote://my|bucket(#0)/foo{}/[?]bar~/b&z/a: 
-c.txt"));
+  ASSERT_TRUE(
+      remotefs.Matches("remote://my|bucket(#%)/foo{abc}/[_]bar~/b&z/a: 
ab-c.txt"));
+
+  Globber wildcards("remote://bucket?/f\\?o/\\*/*.parquet");
+  ASSERT_TRUE(wildcards.Matches("remote://bucket0/f?o/*/abc.parquet"));
+  ASSERT_FALSE(wildcards.Matches("remote://bucket0/foo/ab/a.parquet"));
+}

Review Comment:
   Sure, I'll add tests with an empty pattern and a "\*" to show that * is not 
recursive



##########
cpp/src/arrow/filesystem/filesystem_test.cc:
##########
@@ -265,6 +265,24 @@ TEST(PathUtil, ToSlashes) {
 #endif
 }
 
+TEST(PathUtil, Globber) {
+  Globber localfs_linux("/f?o/bar/a?/1*.txt");
+  ASSERT_TRUE(localfs_linux.Matches("/foo/bar/a1/1.txt"));
+  ASSERT_TRUE(localfs_linux.Matches("/f#o/bar/ab/1000.txt"));
+
+  Globber localfs_windows("C:/f?o/bar/a?/1*.txt");
+  ASSERT_TRUE(localfs_windows.Matches("C:/f_o/bar/ac/1000.txt"));
+
+  Globber remotefs("remote://my|bucket(#?)/foo{*}/[?]bar~/b&z/a: *-c.txt");
+  ASSERT_TRUE(remotefs.Matches("remote://my|bucket(#0)/foo{}/[?]bar~/b&z/a: 
-c.txt"));
+  ASSERT_TRUE(
+      remotefs.Matches("remote://my|bucket(#%)/foo{abc}/[_]bar~/b&z/a: 
ab-c.txt"));
+
+  Globber wildcards("remote://bucket?/f\\?o/\\*/*.parquet");
+  ASSERT_TRUE(wildcards.Matches("remote://bucket0/f?o/*/abc.parquet"));
+  ASSERT_FALSE(wildcards.Matches("remote://bucket0/foo/ab/a.parquet"));
+}

Review Comment:
   Sure, I'll add tests with an empty pattern and a "\\*" to show that * is not 
recursive



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to