Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions api/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class String
// invalid string (i.e., "if (s)" will be true afterwards)
bool reserve(unsigned int size);
inline unsigned int length(void) const {return len;}
inline bool isEmpty(void) const { return length() == 0; }

// creates a copy of the assigned value. if the value is null or
// invalid, or if the memory allocation fails, the string will be
Expand Down
29 changes: 29 additions & 0 deletions test/src/String/test_isEmpty.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2023 Arduino. All rights reserved.
*/

/**************************************************************************************
* INCLUDE
**************************************************************************************/

#include <catch.hpp>

#include <api/String.h>

#include "StringPrinter.h"

/**************************************************************************************
* TEST CODE
**************************************************************************************/

TEST_CASE ("Testing String::isEmpty when string is empty", "[String-isEmpty-01]")
{
arduino::String str;
REQUIRE(str.isEmpty());
}

TEST_CASE ("Testing String::isEmpty when string contains characters", "[String-isEmpty-02]")
{
arduino::String str("Testing String::isEmpty");
REQUIRE(!str.isEmpty());
}