niyue commented on code in PR #37752:
URL: https://github.com/apache/arrow/pull/37752#discussion_r1330914271


##########
cpp/src/gandiva/exported_funcs_registry_test.cc:
##########
@@ -0,0 +1,28 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "gandiva/exported_funcs_registry.h"
+#include <gtest/gtest.h>
+#include "gandiva/exported_funcs.h"
+
+namespace gandiva {
+TEST(ExportedFuncsRegistry, RegistrationOnlyOnce) {
+  gandiva::RegisterExportedFuncs();
+  auto const& registered_list = ExportedFuncsRegistry::registered();
+  EXPECT_EQ(registered_list.size(), 6);

Review Comment:
   > Can you also add a unit test to make sure each function is only registered 
once?
   @js8544 I figured out I can use `FRIEND_TEST` macro to test a private 
method, and I added a test case to verify each `ExportedFuncsBase` is only 
registered once, but currently I have to use a hard coded value `6` here since 
we have 6 set of functions to be registered (ExportedStubFunctions, 
ExportedContextFunctions, ExportedTimeFunctions, ExportedDecimalFunctions, 
ExportedStringFunctions, ExportedHashFunctions), but this test case needs 
additional maintenance if we add more  `ExportedFuncsBase` in the future. Let 
me know if there is other approach for addressing this concern. Thanks.



##########
cpp/src/gandiva/exported_funcs_registry_test.cc:
##########
@@ -0,0 +1,28 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "gandiva/exported_funcs_registry.h"
+#include <gtest/gtest.h>
+#include "gandiva/exported_funcs.h"
+
+namespace gandiva {
+TEST(ExportedFuncsRegistry, RegistrationOnlyOnce) {
+  gandiva::RegisterExportedFuncs();
+  auto const& registered_list = ExportedFuncsRegistry::registered();
+  EXPECT_EQ(registered_list.size(), 6);

Review Comment:
   > Can you also add a unit test to make sure each function is only registered 
once?
   
   @js8544 I figured out I can use `FRIEND_TEST` macro to test a private 
method, and I added a test case to verify each `ExportedFuncsBase` is only 
registered once, but currently I have to use a hard coded value `6` here since 
we have 6 set of functions to be registered (ExportedStubFunctions, 
ExportedContextFunctions, ExportedTimeFunctions, ExportedDecimalFunctions, 
ExportedStringFunctions, ExportedHashFunctions), but this test case needs 
additional maintenance if we add more  `ExportedFuncsBase` in the future. Let 
me know if there is other approach for addressing this concern. Thanks.



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