[libc-commits] [PATCH] D82133: Add strcmp function to libc.
Chris Gyurgyik via Phabricator via libc-commits
libc-commits at lists.llvm.org
Thu Jun 18 16:59:08 PDT 2020
cgyurgyik created this revision.
cgyurgyik added a project: libc-project.
Herald added a subscriber: libc-commits.
cgyurgyik removed a project: libc-project.
Herald added a project: libc-project.
cgyurgyik abandoned this revision.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D82133
Files:
libc/test/src/string/strcmp_test.cpp
Index: libc/test/src/string/strcmp_test.cpp
===================================================================
--- libc/test/src/string/strcmp_test.cpp
+++ libc/test/src/string/strcmp_test.cpp
@@ -16,7 +16,6 @@
ASSERT_EQ(result, 0);
}
-<<<<<<< HEAD
TEST(StrCmpTest, EmptyStringShouldNotEqualNonEmptyString) {
const char *empty = "";
const char *s2 = "abc";
@@ -31,8 +30,6 @@
ASSERT_EQ(result, 49);
}
-=======
->>>>>>> 3e77db0445101d39c49274da6c375b8792e510b9
TEST(StrCmpTest, EqualStringsShouldReturnZero) {
const char *s1 = "abc";
const char *s2 = "abc";
@@ -41,37 +38,22 @@
}
TEST(StrCmpTest, ShouldReturnResultOfFirstDifference) {
-<<<<<<< HEAD
const char *s1 = "___B42__";
const char *s2 = "___C55__";
const int result = __llvm_libc::strcmp(s1, s2);
// This should return 'B' - 'C' = -1.
-=======
- const char *s1 = "aaaB42";
- const char *s2 = "aaaC55";
- const int result = __llvm_libc::strcmp(s1, s2);
- // This should return 'C' - 'B', which is equal to -1.
->>>>>>> 3e77db0445101d39c49274da6c375b8792e510b9
ASSERT_EQ(result, -1);
}
TEST(StrCmpTest, CapitalizedLetterShouldNotBeEqual) {
-<<<<<<< HEAD
const char *s1 = "abcd";
const char *s2 = "abCd";
const int result = __llvm_libc::strcmp(s1, s2);
// 'c' - 'C' = 32.
-=======
- const char *s1 = "abcd";
- const char *s2 = "abCd";
- const int result = __llvm_libc::strcmp(s1, s2);
- // 'c' - 'C' is equal to 32.
->>>>>>> 3e77db0445101d39c49274da6c375b8792e510b9
ASSERT_EQ(result, 32);
}
TEST(StrCmpTest, UnequalLengthStringsShouldNotReturnZero) {
-<<<<<<< HEAD
const char *s1 = "abc";
const char *s2 = "abcd";
const int result = __llvm_libc::strcmp(s1, s2);
@@ -88,23 +70,5 @@
result = __llvm_libc::strcmp(a, b);
// 'a' - 'b' = -1.
-=======
- const char *s1 = "abc";
- const char *s2 = "abcd";
- const int result = __llvm_libc::strcmp(s1, s2);
- // '\0' - 'd' is equal to -100.
- ASSERT_EQ(result, -100);
-}
-
-TEST(StrCmpTest, OrderingSwapChangesSign) {
- const char *a = "a";
- const char *b = "b";
- int result = __llvm_libc::strcmp(b, a);
- // 'b' - 'a' is equal to 1.
- ASSERT_EQ(result, 1);
-
- result = __llvm_libc::strcmp(a, b);
- // 'a' - 'b' is equal to -1.
->>>>>>> 3e77db0445101d39c49274da6c375b8792e510b9
ASSERT_EQ(result, -1);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82133.271870.patch
Type: text/x-patch
Size: 2311 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20200618/46987af2/attachment-0001.bin>
More information about the libc-commits
mailing list