aboutsummaryrefslogtreecommitdiff
path: root/tests/string_test.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2020-08-12 14:25:41 -0700
committerElliott Hughes <enh@google.com>2020-08-12 15:52:14 -0700
commit7cebf835f310650f67b254295a685918681656fc (patch)
treedaf485447fccb691750149c465b2c629adf6e305 /tests/string_test.cpp
parenta4110def5cec22306313a34fff64b5810c9b1792 (diff)
downloadbionic-7cebf835f310650f67b254295a685918681656fc.tar.gz
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
Diffstat (limited to 'tests/string_test.cpp')
-rw-r--r--tests/string_test.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/string_test.cpp b/tests/string_test.cpp
index fd7a551c3..22be85241 100644
--- a/tests/string_test.cpp
+++ b/tests/string_test.cpp
@@ -64,6 +64,11 @@ TEST(STRING_TEST, strerror) {
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 @@ TEST(STRING_TEST, strcoll_smoke) {
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 @@ TEST(STRING_TEST, strxfrm_smoke) {
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];