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

Commit f7311d9

Browse files
Add tests for String operator == and !=
This expands the existing tests for String.equals to also test operator == and !=. These should be equivalent (the operators just call equals), but add tests to ensure this.
1 parent 0c8dbd6 commit f7311d9

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

‎test/src/String/test_comparisonFunc.cpp‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,72 @@ TEST_CASE ("Testing String::equals(const String &) with exit status PASS", "[Str
2222
REQUIRE(str1.equals(str2) == 1);
2323
}
2424

25+
TEST_CASE ("Testing String::operator==(const String &) with exit status PASS", "[String-equals-01]")
26+
{
27+
arduino::String str1("Hello"), str2("Hello");
28+
REQUIRE(str1 == str2);
29+
}
30+
31+
TEST_CASE ("Testing String::operator!=(const String &) with exit status FAIL", "[String-equals-01]")
32+
{
33+
arduino::String str1("Hello"), str2("Hello");
34+
REQUIRE_FALSE(str1 != str2);
35+
}
36+
2537
TEST_CASE ("Testing String::equals(const String &) with exit status FAIL", "[String-equals-02]")
2638
{
2739
arduino::String str1("Hello"), str2("World");
2840
REQUIRE(str1.equals(str2) == 0);
2941
}
3042

43+
TEST_CASE ("Testing String::operator==(const String &) with exit status FAIL", "[String-equals-02]")
44+
{
45+
arduino::String str1("Hello"), str2("World");
46+
REQUIRE_FALSE(str1 == str2);
47+
}
48+
49+
TEST_CASE ("Testing String::operator !=(const String &) with exit status PASS", "[String-equals-02]")
50+
{
51+
arduino::String str1("Hello"), str2("World");
52+
REQUIRE(str1 != str2);
53+
}
54+
3155
TEST_CASE ("Testing String::equals(const char *) with exit status PASS", "[String-equals-03]")
3256
{
3357
arduino::String str1("Hello");
3458
REQUIRE(str1.equals("Hello") == 1);
3559
}
3660

61+
TEST_CASE ("Testing String::operator ==(const char *) with exit status PASS", "[String-equals-03]")
62+
{
63+
arduino::String str1("Hello");
64+
REQUIRE(str1 == "Hello");
65+
}
66+
67+
TEST_CASE ("Testing String::operator !=(const char *) with exit status FAIL", "[String-equals-03]")
68+
{
69+
arduino::String str1("Hello");
70+
REQUIRE_FALSE(str1 != "Hello");
71+
}
72+
3773
TEST_CASE ("Testing String::equals(const char *) with exit status FAIL", "[String-equals-04]")
3874
{
3975
arduino::String str1("Hello");
4076
REQUIRE(str1.equals("World") == 0);
4177
}
4278

79+
TEST_CASE ("Testing String::operator ==(const char *) with exit status FAIL", "[String-equals-04]")
80+
{
81+
arduino::String str1("Hello");
82+
REQUIRE_FALSE(str1 == "World");
83+
}
84+
85+
TEST_CASE ("Testing String::operator !=(const char *) with exit status PASS", "[String-equals-04]")
86+
{
87+
arduino::String str1("Hello");
88+
REQUIRE(str1 != "World");
89+
}
90+
4391
TEST_CASE ("Testing String::equalsIgnoreCase(const String &) PASS with NON-empty string", "[String-equalsIgnoreCase-05]")
4492
{
4593
arduino::String str1("Hello"), str2("Hello");

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /