summaryrefslogtreecommitdiff
path: root/runtime/native_stack_dump_test.cc
diff options
context:
space:
mode:
author David Srbecky <dsrbecky@google.com> 2022-09-29 14:40:10 +0100
committer Treehugger Robot <treehugger-gerrit@google.com> 2022-09-30 16:03:54 +0000
commit6940a814d9d5724ee715bb9b8d61351fd1923b2b (patch)
treef98d2803dc31cf03d3fe7b3008779d552390916c /runtime/native_stack_dump_test.cc
parent94d89030ca27dc45ffc7b2689cb7754b78db3a28 (diff)
ANR: Improve parameter removal
Support removing multiple parameters since functions can be defined inside function (lambdas are very common case). Bug: 189881220 Test: manual ANR Change-Id: I9c4ad139bcee09811cb7356ee48199b16483d971
Diffstat (limited to 'runtime/native_stack_dump_test.cc')
-rw-r--r--runtime/native_stack_dump_test.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/runtime/native_stack_dump_test.cc b/runtime/native_stack_dump_test.cc
new file mode 100644
index 0000000000..4446495ede
--- /dev/null
+++ b/runtime/native_stack_dump_test.cc
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed 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 "native_stack_dump.h"
+
+#include <gtest/gtest.h>
+
+namespace art {
+
+TEST(StripParametersTest, ValidInput) {
+ EXPECT_EQ(StripParameters("foo(int)"), "foo");
+ EXPECT_EQ(StripParameters("foo(int, std::string)"), "foo");
+ EXPECT_EQ(StripParameters("foo(int) const"), "foo const");
+ EXPECT_EQ(StripParameters("foo(int)::bar(int)"), "foo::bar");
+ EXPECT_EQ(StripParameters("foo<int>(int)"), "foo<int>");
+}
+
+TEST(StripParametersTest, InvalidInput) {
+ EXPECT_EQ(StripParameters("foo(int?"), "foo(int?");
+ EXPECT_EQ(StripParameters("foo?int)"), "foo?int)");
+ EXPECT_EQ(StripParameters("(foo(int)"), "(foo");
+ EXPECT_EQ(StripParameters(")foo(int)"), ")foo");
+ EXPECT_EQ(StripParameters("foo(((int)))"), "foo");
+}
+
+} // namespace art