Various coverage improvements.
Mostly from extra test cases, but also:
* Move the fgets size < 0 assertion into fgets.
* Use ELF aliases for strtoq/strtouq rather than duplicating code.
* Don't check uname() succeeded, since it can't fail.
Test: treehugger
Change-Id: I2e6b3b88b0a3eb16bd68be68b9bc9f40d8043291
diff --git a/tests/string_test.cpp b/tests/string_test.cpp
index fd7a551..22be852 100644
--- a/tests/string_test.cpp
+++ b/tests/string_test.cpp
@@ -64,6 +64,11 @@
ASSERT_STREQ("Unknown error 134", strerror(EHWPOISON + 1));
}
+TEST(STRING_TEST, strerror_l) {
+ // bionic just forwards to strerror(3).
+ ASSERT_STREQ("Success", strerror_l(0, LC_GLOBAL_LOCALE));
+}
+
#if defined(__BIONIC__)
static void* ConcurrentStrErrorFn(void*) {
bool equal = (strcmp("Unknown error 2002", strerror(2002)) == 0);
@@ -1607,6 +1612,13 @@
ASSERT_TRUE(strcoll("aac", "aab") > 0);
}
+TEST(STRING_TEST, strcoll_l_smoke) {
+ // bionic just forwards to strcoll(3).
+ ASSERT_TRUE(strcoll_l("aab", "aac", LC_GLOBAL_LOCALE) < 0);
+ ASSERT_TRUE(strcoll_l("aab", "aab", LC_GLOBAL_LOCALE) == 0);
+ ASSERT_TRUE(strcoll_l("aac", "aab", LC_GLOBAL_LOCALE) > 0);
+}
+
TEST(STRING_TEST, strxfrm_smoke) {
const char* src1 = "aab";
char dst1[16] = {};
@@ -1628,6 +1640,16 @@
ASSERT_TRUE(strcmp(dst1, dst2) < 0);
}
+TEST(STRING_TEST, strxfrm_l_smoke) {
+ // bionic just forwards to strxfrm(3), so this is a subset of the
+ // strxfrm test.
+ const char* src1 = "aab";
+ char dst1[16] = {};
+ ASSERT_EQ(strxfrm_l(dst1, src1, 0, LC_GLOBAL_LOCALE), 3U);
+ ASSERT_STREQ(dst1, "");
+ ASSERT_EQ(strxfrm_l(dst1, src1, sizeof(dst1), LC_GLOBAL_LOCALE), 3U);
+}
+
TEST(STRING_TEST, memccpy_smoke) {
char dst[32];