Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite9d4d01

Browse files
authored
Merge pull request#205 from jboynes/test_compareTo
Do not rely on the actual value returned from strcmp in tests, only the sign.
2 parents0ecb1aa +296baa0 commite9d4d01

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

‎test/src/String/test_compareTo.cpp‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ TEST_CASE ("Testing String::compareTo(const String &)", "[String-compareTo-01]")
2727
WHEN ("str2 is empty")
2828
{
2929
arduino::Stringstr1("Hello"), str2;
30-
REQUIRE(str1.compareTo(str2)==strcmp(str1.c_str(), str2.c_str()));
30+
REQUIRE(str1.compareTo(str2)>0);
3131
}
3232

3333
WHEN ("str1 is empty")
3434
{
3535
arduino::String str1,str2("Hello");
36-
REQUIRE(str1.compareTo(str2)==strcmp(str1.c_str(), str2.c_str()));
36+
REQUIRE(str1.compareTo(str2)<0);
3737
}
3838
}
3939

@@ -47,14 +47,14 @@ TEST_CASE ("Testing String::compareTo(const char *)", "[String-compareTo-02]")
4747

4848
WHEN ("Passed string is empty")
4949
{
50-
arduino::Stringstr1("Hello"),str2("");
51-
REQUIRE(str1.compareTo("")==strcmp(str1.c_str(), str2.c_str()));
50+
arduino::Stringstr("Hello");
51+
REQUIRE(str.compareTo("")>0);
5252
}
5353

5454
WHEN ("Passed string is compared with empty string")
5555
{
56-
arduino::Stringstr1,str2("Hello");
57-
REQUIRE(str1.compareTo("Hello") ==strcmp(str1.c_str(), str2.c_str()));
56+
arduino::Stringstr;
57+
REQUIRE(str.compareTo("") ==0);
5858
}
5959
}
6060

@@ -64,17 +64,17 @@ TEST_CASE ("Testing String::compareTo(const char *) with empty buffer", "[String
6464
{
6565
char *buffer =NULL;
6666

67-
arduino::Stringstr1("Hello");
68-
REQUIRE(str1.compareTo(buffer) !=0);
67+
arduino::Stringstr("Hello");
68+
REQUIRE(str.compareTo(buffer) !=0);
6969
}
7070

7171
WHEN ("First string does NOT have a valid buffer")
7272
{
7373
char *buffer1 =NULL;
7474
char *buffer2 =NULL;
7575

76-
arduino::Stringstr1(buffer1);
77-
REQUIRE(str1.compareTo(buffer2) ==0);
76+
arduino::Stringstr(buffer1);
77+
REQUIRE(str.compareTo(buffer2) ==0);
7878
}
7979
}
8080

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp