Merge "Add a missing strtol() family test and a hex benchmark." into main
diff --git a/benchmarks/stdlib_benchmark.cpp b/benchmarks/stdlib_benchmark.cpp
index 9be72e7..7680b40 100644
--- a/benchmarks/stdlib_benchmark.cpp
+++ b/benchmarks/stdlib_benchmark.cpp
@@ -235,3 +235,6 @@
BIONIC_TRIVIAL_BENCHMARK(BM_stdlib_strtoll, strtoll(" -123", nullptr, 0));
BIONIC_TRIVIAL_BENCHMARK(BM_stdlib_strtoul, strtoul(" -123", nullptr, 0));
BIONIC_TRIVIAL_BENCHMARK(BM_stdlib_strtoull, strtoull(" -123", nullptr, 0));
+
+BIONIC_TRIVIAL_BENCHMARK(BM_stdlib_strtol_hex, strtol("0xdeadbeef", nullptr, 0));
+BIONIC_TRIVIAL_BENCHMARK(BM_stdlib_strtoul_hex, strtoul("0xdeadbeef", nullptr, 0));
diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp
index 21c79c8..4793150 100644
--- a/tests/stdlib_test.cpp
+++ b/tests/stdlib_test.cpp
@@ -901,6 +901,12 @@
ASSERT_ERRNO(ERANGE);
ASSERT_EQ('\0', *end_p);
+ // Junk at the end of a valid conversion.
+ errno = 0;
+ ASSERT_EQ(static_cast<T>(123), fn("123abc", &end_p, 0));
+ ASSERT_ERRNO(0);
+ ASSERT_STREQ("abc", end_p);
+
// In case of overflow, strto* leaves us pointing past the end of the number,
// not at the digit that overflowed.
end_p = nullptr;