Skip to content

Commit 5e84fbd

Browse files
authored
Add DataTable::isNull() (#51)
Add function `DataTable::isNull()` to address #50. Add related test of functionality.
1 parent ea7a104 commit 5e84fbd

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

include/DataTable.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ namespace Data {
212212
virtual DataTableShape getShape() const = 0;
213213

214214
virtual bool empty() const = 0;
215+
216+
virtual bool isNull() const = 0;
215217
};
216218

217219
using IDataTablePtr = std::shared_ptr<Data::IDataTable>;
@@ -568,6 +570,10 @@ namespace Data {
568570
/// @brief Test if the table is empty
569571
/// @return true if no rows, false if contains data
570572
bool empty() const override { return (this->nrows() == 0); }
573+
574+
/// @brief Test if the table contains no data at all
575+
/// @return true if `this->data` is empty, false otherwise
576+
bool isNull() const override { return this->data.empty(); }
571577
};
572578
} // namespace Data
573579

test/DataTableTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,11 @@ TEST_F(DataTableTest, TableEmptyAfterJoin) {
780780
EXPECT_TRUE(resultTable->empty());
781781
}
782782

783+
TEST_F(DataTableTest, TableNull) {
784+
Data::DataTable dt;
785+
EXPECT_TRUE(dt.isNull());
786+
}
787+
783788
TEST_F(DataTableTest, innerJoin) {
784789
std::vector<std::string> headerOrder1 = {"id", "test1", "test2", "test3"};
785790
std::map<std::string, std::vector<std::string>> d1;

0 commit comments

Comments
 (0)