@@ -40,14 +40,16 @@ template <auto Func> struct StrchrTest : public LIBC_NAMESPACE::testing::Test {
40
40
const char *src = " abcde" ;
41
41
42
42
// Should return null terminator.
43
- ASSERT_STREQ (Func (src, ' \0 ' ), " " );
43
+ const char *nul_terminator = Func (src, ' \0 ' );
44
+ ASSERT_TRUE (nul_terminator != nullptr );
45
+ ASSERT_STREQ (nul_terminator, " " );
44
46
// Source string should not change.
45
47
ASSERT_STREQ (src, " abcde" );
46
48
}
47
49
48
50
void characterNotWithinStringShouldReturnNullptr () {
49
51
// Since 'z' is not within the string, should return nullptr.
50
- ASSERT_STREQ (Func (" 123?" , ' z' ), nullptr );
52
+ ASSERT_TRUE (Func (" 123?" , ' z' ) == nullptr );
51
53
}
52
54
53
55
void theSourceShouldNotChange () {
@@ -74,11 +76,12 @@ template <auto Func> struct StrchrTest : public LIBC_NAMESPACE::testing::Test {
74
76
75
77
void emptyStringShouldOnlyMatchNullTerminator () {
76
78
// Null terminator should match.
77
- ASSERT_STREQ (Func (" " , ' \0 ' ), " " );
79
+ const char empty_string[] = " " ;
80
+ ASSERT_TRUE (Func (empty_string, ' \0 ' ) == empty_string);
78
81
// All other characters should not match.
79
- ASSERT_STREQ (Func (" " , ' Z' ), nullptr );
80
- ASSERT_STREQ (Func (" " , ' 3' ), nullptr );
81
- ASSERT_STREQ (Func (" " , ' *' ), nullptr );
82
+ ASSERT_TRUE (Func (" " , ' Z' ) == nullptr );
83
+ ASSERT_TRUE (Func (" " , ' 3' ) == nullptr );
84
+ ASSERT_TRUE (Func (" " , ' *' ) == nullptr );
82
85
}
83
86
};
84
87
@@ -114,25 +117,25 @@ template <auto Func> struct StrrchrTest : public LIBC_NAMESPACE::testing::Test {
114
117
const char *src = " abcde" ;
115
118
116
119
// Should return null terminator.
117
- ASSERT_STREQ (Func (src, ' \0 ' ), " " );
120
+ ASSERT_TRUE (Func (src, ' \0 ' ) != nullptr );
118
121
// Source string should not change.
119
122
ASSERT_STREQ (src, " abcde" );
120
123
}
121
124
122
125
void findsLastBehindFirstNullTerminator () {
123
126
static const char src[6 ] = {' a' , ' a' , ' \0 ' , ' b' , ' \0 ' , ' c' };
124
127
// 'b' is behind a null terminator, so should not be found.
125
- ASSERT_STREQ (Func (src, ' b' ), nullptr );
128
+ ASSERT_TRUE (Func (src, ' b' ) == nullptr );
126
129
// Same goes for 'c'.
127
- ASSERT_STREQ (Func (src, ' c' ), nullptr );
130
+ ASSERT_TRUE (Func (src, ' c' ) == nullptr );
128
131
129
132
// Should find the second of the two a's.
130
133
ASSERT_STREQ (Func (src, ' a' ), " a" );
131
134
}
132
135
133
136
void characterNotWithinStringShouldReturnNullptr () {
134
137
// Since 'z' is not within the string, should return nullptr.
135
- ASSERT_STREQ (Func (" 123?" , ' z' ), nullptr );
138
+ ASSERT_TRUE (Func (" 123?" , ' z' ) == nullptr );
136
139
}
137
140
138
141
void shouldFindLastOfDuplicates () {
@@ -146,11 +149,12 @@ template <auto Func> struct StrrchrTest : public LIBC_NAMESPACE::testing::Test {
146
149
147
150
void emptyStringShouldOnlyMatchNullTerminator () {
148
151
// Null terminator should match.
149
- ASSERT_STREQ (Func (" " , ' \0 ' ), " " );
152
+ const char empty_string[] = " " ;
153
+ ASSERT_TRUE (Func (empty_string, ' \0 ' ) == empty_string);
150
154
// All other characters should not match.
151
- ASSERT_STREQ (Func (" " , ' A' ), nullptr );
152
- ASSERT_STREQ (Func (" " , ' 2' ), nullptr );
153
- ASSERT_STREQ (Func (" " , ' *' ), nullptr );
155
+ ASSERT_TRUE (Func (" " , ' A' ) == nullptr );
156
+ ASSERT_TRUE (Func (" " , ' 2' ) == nullptr );
157
+ ASSERT_TRUE (Func (" " , ' *' ) == nullptr );
154
158
}
155
159
};
156
160
0 commit comments