Skip to content

Simplify string comparisons in tests and fix bug in String::compareTo #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 25, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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.
  • Loading branch information
matthijskooijman committed Jan 25, 2021
commit f7311d936cd3ad67a38a206745f35ac41a0e80d8
48 changes: 48 additions & 0 deletions test/src/String/test_comparisonFunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,72 @@ TEST_CASE ("Testing String::equals(const String &) with exit status PASS", "[Str
REQUIRE(str1.equals(str2) == 1);
}

TEST_CASE ("Testing String::operator==(const String &) with exit status PASS", "[String-equals-01]")
{
arduino::String str1("Hello"), str2("Hello");
REQUIRE(str1 == str2);
}

TEST_CASE ("Testing String::operator!=(const String &) with exit status FAIL", "[String-equals-01]")
{
arduino::String str1("Hello"), str2("Hello");
REQUIRE_FALSE(str1 != str2);
}

TEST_CASE ("Testing String::equals(const String &) with exit status FAIL", "[String-equals-02]")
{
arduino::String str1("Hello"), str2("World");
REQUIRE(str1.equals(str2) == 0);
}

TEST_CASE ("Testing String::operator==(const String &) with exit status FAIL", "[String-equals-02]")
{
arduino::String str1("Hello"), str2("World");
REQUIRE_FALSE(str1 == str2);
}

TEST_CASE ("Testing String::operator !=(const String &) with exit status PASS", "[String-equals-02]")
{
arduino::String str1("Hello"), str2("World");
REQUIRE(str1 != str2);
}

TEST_CASE ("Testing String::equals(const char *) with exit status PASS", "[String-equals-03]")
{
arduino::String str1("Hello");
REQUIRE(str1.equals("Hello") == 1);
}

TEST_CASE ("Testing String::operator ==(const char *) with exit status PASS", "[String-equals-03]")
{
arduino::String str1("Hello");
REQUIRE(str1 == "Hello");
}

TEST_CASE ("Testing String::operator !=(const char *) with exit status FAIL", "[String-equals-03]")
{
arduino::String str1("Hello");
REQUIRE_FALSE(str1 != "Hello");
}

TEST_CASE ("Testing String::equals(const char *) with exit status FAIL", "[String-equals-04]")
{
arduino::String str1("Hello");
REQUIRE(str1.equals("World") == 0);
}

TEST_CASE ("Testing String::operator ==(const char *) with exit status FAIL", "[String-equals-04]")
{
arduino::String str1("Hello");
REQUIRE_FALSE(str1 == "World");
}

TEST_CASE ("Testing String::operator !=(const char *) with exit status PASS", "[String-equals-04]")
{
arduino::String str1("Hello");
REQUIRE(str1 != "World");
}

TEST_CASE ("Testing String::equalsIgnoreCase(const String &) PASS with NON-empty string", "[String-equalsIgnoreCase-05]")
{
arduino::String str1("Hello"), str2("Hello");
Expand Down