Reranko05 commented on code in PR #49660:
URL: https://github.com/apache/arrow/pull/49660#discussion_r3052213926


##########
cpp/src/arrow/util/string_test.cc:
##########
@@ -232,12 +233,79 @@ TEST(ToChars, FloatingPoint) {
     // to std::to_string which may make ad hoc formatting choices, so we cannot
     // really test much about the result.
     auto result = ToChars(0.0f);
-    ASSERT_TRUE(result.starts_with("0")) << result;
+    ASSERT_TRUE(result.rfind("0", 0) == 0) << result;
     result = ToChars(0.25);
-    ASSERT_TRUE(result.starts_with("0.25")) << result;
+    ASSERT_TRUE(result.rfind("0.25", 0) == 0) << result;
   }
 }
 
+TEST(Base64DecodeTest, ValidInputs) {
+  auto r1 = arrow::util::base64_decode("Zg==");
+  ASSERT_TRUE(r1.ok());
+  EXPECT_EQ(r1.ValueOrDie(), "f");
+  auto r2 = arrow::util::base64_decode("Zm8=");
+  ASSERT_TRUE(r2.ok());
+  EXPECT_EQ(r2.ValueOrDie(), "fo");
+  auto r3 = arrow::util::base64_decode("Zm9v");
+  ASSERT_TRUE(r3.ok());
+  EXPECT_EQ(r3.ValueOrDie(), "foo");
+  auto r4 = arrow::util::base64_decode("aGVsbG8gd29ybGQ=");
+  ASSERT_TRUE(r4.ok());
+  EXPECT_EQ(r4.ValueOrDie(), "hello world");
+}
+
+TEST(Base64DecodeTest, InvalidLength) {
+  auto r1 = arrow::util::base64_decode("abc");
+  ASSERT_FALSE(r1.ok());
+  auto r2 = arrow::util::base64_decode("abcde");
+  ASSERT_FALSE(r2.ok());
+}
+
+TEST(Base64DecodeTest, InvalidCharacters) {
+  auto r1 = arrow::util::base64_decode("ab$=");
+  ASSERT_FALSE(r1.ok());
+  auto r2 = arrow::util::base64_decode("Zm9v*");
+  ASSERT_FALSE(r2.ok());
+  auto r3 = arrow::util::base64_decode("abcd$AAA");
+  ASSERT_FALSE(r3.ok());
+}
+
+TEST(Base64DecodeTest, InvalidPadding) {
+  auto r1 = arrow::util::base64_decode("ab=c");
+  ASSERT_FALSE(r1.ok());
+  auto r2 = arrow::util::base64_decode("abc===");
+  ASSERT_FALSE(r2.ok());
+  auto r3 = arrow::util::base64_decode("abcd=AAA");
+  ASSERT_FALSE(r3.ok());
+  auto r4 = arrow::util::base64_decode("Zm=9v");
+  ASSERT_FALSE(r4.ok());
+}
+
+TEST(Base64DecodeTest, EdgeCases) {
+  auto r1 = arrow::util::base64_decode("====");
+  ASSERT_FALSE(r1.ok());

Review Comment:
   You are right.. this case should fall under invalid padding I’ll move it 
accordingly.



-- 
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