diff --git a/cpp/include/gar/graph_info.h b/cpp/include/gar/graph_info.h index 9e0cbfb54..ff0ab0ff0 100644 --- a/cpp/include/gar/graph_info.h +++ b/cpp/include/gar/graph_info.h @@ -187,6 +187,8 @@ class VertexInfo { const std::string& prefix = "", std::shared_ptr version = nullptr); + ~VertexInfo(); + /** * Adds a property group to the vertex info and returns a new VertexInfo * @@ -402,6 +404,8 @@ class EdgeInfo { const std::string& prefix = "", std::shared_ptr version = nullptr); + ~EdgeInfo(); + /** * Add an adjacency list information to the edge info and returns a new * EdgeInfo. The adjacency list information indicating the adjacency list @@ -699,6 +703,8 @@ class GraphInfo { std::shared_ptr version = nullptr, const std::unordered_map& extra_info = {}); + ~GraphInfo(); + /** * @brief Loads the input file as a `GraphInfo` instance. * @param path The path of the YAML file. diff --git a/cpp/src/graph_info.cc b/cpp/src/graph_info.cc index b8998c3bc..e34555826 100644 --- a/cpp/src/graph_info.cc +++ b/cpp/src/graph_info.cc @@ -89,7 +89,7 @@ bool operator==(const Property& lhs, const Property& rhs) { PropertyGroup::PropertyGroup(const std::vector& properties, FileType file_type, const std::string& prefix) : properties_(properties), file_type_(file_type), prefix_(prefix) { - if (prefix_.empty()) { + if (prefix_.empty() && !properties_.empty()) { for (const auto& p : properties_) { prefix_ += p.name + REGULAR_SEPARATOR; } @@ -116,6 +116,9 @@ bool PropertyGroup::IsValidated() const { file_type_ != FileType::ORC)) { return false; } + if (properties_.empty()) { + return false; + } std::unordered_set check_property_unique_set; for (const auto& p : properties_) { if (p.name.empty() || p.type == nullptr) { @@ -139,6 +142,10 @@ bool PropertyGroup::IsValidated() const { std::shared_ptr CreatePropertyGroup( const std::vector& properties, FileType file_type, const std::string& prefix) { + if (properties.empty()) { + // empty property group is not allowed + return nullptr; + } return std::make_shared(properties, file_type, prefix); } @@ -192,6 +199,9 @@ class VertexInfo::Impl { } for (size_t i = 0; i < property_groups_.size(); i++) { const auto& pg = property_groups_[i]; + if (!pg) { + continue; + } for (const auto& p : pg->GetProperties()) { property_name_to_index_.emplace(p.name, i); property_name_to_primary_.emplace(p.name, p.is_primary); @@ -243,6 +253,8 @@ VertexInfo::VertexInfo(const std::string& label, IdType chunk_size, std::shared_ptr version) : impl_(new Impl(label, chunk_size, prefix, property_groups, version)) {} +VertexInfo::~VertexInfo() = default; + const std::string& VertexInfo::GetLabel() const { return impl_->label_; } IdType VertexInfo::GetChunkSize() const { return impl_->chunk_size_; } @@ -362,6 +374,9 @@ std::shared_ptr CreateVertexInfo( const std::string& label, IdType chunk_size, const PropertyGroupVector& property_groups, const std::string& prefix, std::shared_ptr version) { + if (label.empty() || chunk_size <= 0) { + return nullptr; + } return std::make_shared(label, chunk_size, property_groups, prefix, version); } @@ -425,33 +440,37 @@ Result VertexInfo::Dump() const noexcept { if (!IsValidated()) { return Status::Invalid("The vertex info is not validated"); } + std::string dump_string; ::Yaml::Node node; - node["label"] = impl_->label_; - node["chunk_size"] = std::to_string(impl_->chunk_size_); - node["prefix"] = impl_->prefix_; - for (const auto& pg : impl_->property_groups_) { - ::Yaml::Node pg_node; - if (!pg->GetPrefix().empty()) { - pg_node["prefix"] = pg->GetPrefix(); + try { + node["label"] = impl_->label_; + node["chunk_size"] = std::to_string(impl_->chunk_size_); + node["prefix"] = impl_->prefix_; + for (const auto& pg : impl_->property_groups_) { + ::Yaml::Node pg_node; + if (!pg->GetPrefix().empty()) { + pg_node["prefix"] = pg->GetPrefix(); + } + pg_node["file_type"] = FileTypeToString(pg->GetFileType()); + for (const auto& p : pg->GetProperties()) { + ::Yaml::Node p_node; + p_node["name"] = p.name; + p_node["data_type"] = p.type->ToTypeName(); + p_node["is_primary"] = p.is_primary ? "true" : "false"; + p_node["is_nullable"] = p.is_nullable ? "true" : "false"; + pg_node["properties"].PushBack(); + pg_node["properties"][pg_node["properties"].Size() - 1] = p_node; + } + node["property_groups"].PushBack(); + node["property_groups"][node["property_groups"].Size() - 1] = pg_node; } - pg_node["file_type"] = FileTypeToString(pg->GetFileType()); - for (const auto& p : pg->GetProperties()) { - ::Yaml::Node p_node; - p_node["name"] = p.name; - p_node["data_type"] = p.type->ToTypeName(); - p_node["is_primary"] = p.is_primary ? "true" : "false"; - p_node["is_nullable"] = p.is_nullable ? "true" : "false"; - pg_node["properties"].PushBack(); - pg_node["properties"][pg_node["properties"].Size() - 1] = p_node; + if (impl_->version_ != nullptr) { + node["version"] = impl_->version_->ToString(); } - node["property_groups"].PushBack(); - node["property_groups"][node["property_groups"].Size() - 1] = pg_node; + ::Yaml::Serialize(node, dump_string); + } catch (const std::exception& e) { + return Status::Invalid("Failed to dump vertex info: ", e.what()); } - if (impl_->version_ != nullptr) { - node["version"] = impl_->version_->ToString(); - } - std::string dump_string; - ::Yaml::Serialize(node, dump_string); return dump_string; } @@ -486,11 +505,18 @@ class EdgeInfo::Impl { REGULAR_SEPARATOR + dst_label_ + "/"; // default prefix } for (size_t i = 0; i < adjacent_lists_.size(); i++) { + if (!adjacent_lists_[i]) { + continue; + } + auto adj_list_type = adjacent_lists_[i]->GetType(); adjacent_list_type_to_index_[adj_list_type] = i; } for (size_t i = 0; i < property_groups_.size(); i++) { const auto& pg = property_groups_[i]; + if (!pg) { + continue; + } for (const auto& p : pg->GetProperties()) { property_name_to_index_.emplace(p.name, i); property_name_to_primary_.emplace(p.name, p.is_primary); @@ -503,7 +529,7 @@ class EdgeInfo::Impl { bool is_validated() const noexcept { if (src_label_.empty() || edge_label_.empty() || dst_label_.empty() || chunk_size_ <= 0 || src_chunk_size_ <= 0 || dst_chunk_size_ <= 0 || - prefix_.empty()) { + prefix_.empty() || adjacent_lists_.empty()) { return false; } @@ -565,6 +591,8 @@ EdgeInfo::EdgeInfo(const std::string& src_label, const std::string& edge_label, src_chunk_size, dst_chunk_size, directed, prefix, adjacent_lists, property_groups, version)) {} +EdgeInfo::~EdgeInfo() = default; + const std::string& EdgeInfo::GetSrcLabel() const { return impl_->src_label_; } const std::string& EdgeInfo::GetEdgeLabel() const { return impl_->edge_label_; } @@ -785,6 +813,11 @@ std::shared_ptr CreateEdgeInfo( const AdjacentListVector& adjacent_lists, const PropertyGroupVector& property_groups, const std::string& prefix, std::shared_ptr version) { + if (src_label.empty() || edge_label.empty() || dst_label.empty() || + chunk_size <= 0 || src_chunk_size <= 0 || dst_chunk_size <= 0 || + adjacent_lists.empty()) { + return nullptr; + } return std::make_shared(src_label, edge_label, dst_label, chunk_size, src_chunk_size, dst_chunk_size, directed, adjacent_lists, property_groups, @@ -876,49 +909,54 @@ Result EdgeInfo::Dump() const noexcept { if (!IsValidated()) { return Status::Invalid("The edge info is not validated."); } + std::string dump_string; ::Yaml::Node node; - node["src_label"] = impl_->src_label_; - node["edge_label"] = impl_->edge_label_; - node["dst_label"] = impl_->dst_label_; - node["chunk_size"] = std::to_string(impl_->chunk_size_); - node["src_chunk_size"] = std::to_string(impl_->src_chunk_size_); - node["dst_chunk_size"] = std::to_string(impl_->dst_chunk_size_); - node["prefix"] = impl_->prefix_; - node["directed"] = impl_->directed_ ? "true" : "false"; - for (const auto& adjacent_list : impl_->adjacent_lists_) { - ::Yaml::Node adj_list_node; - auto adj_list_type = adjacent_list->GetType(); - auto pair = AdjListTypeToOrderedAligned(adj_list_type); - adj_list_node["ordered"] = pair.first ? "true" : "false"; - adj_list_node["aligned_by"] = pair.second; - adj_list_node["prefix"] = adjacent_list->GetPrefix(); - adj_list_node["file_type"] = FileTypeToString(adjacent_list->GetFileType()); - node["adj_lists"].PushBack(); - node["adj_lists"][node["adj_lists"].Size() - 1] = adj_list_node; - } - for (const auto& pg : impl_->property_groups_) { - ::Yaml::Node pg_node; - if (!pg->GetPrefix().empty()) { - pg_node["prefix"] = pg->GetPrefix(); + try { + node["src_label"] = impl_->src_label_; + node["edge_label"] = impl_->edge_label_; + node["dst_label"] = impl_->dst_label_; + node["chunk_size"] = std::to_string(impl_->chunk_size_); + node["src_chunk_size"] = std::to_string(impl_->src_chunk_size_); + node["dst_chunk_size"] = std::to_string(impl_->dst_chunk_size_); + node["prefix"] = impl_->prefix_; + node["directed"] = impl_->directed_ ? "true" : "false"; + for (const auto& adjacent_list : impl_->adjacent_lists_) { + ::Yaml::Node adj_list_node; + auto adj_list_type = adjacent_list->GetType(); + auto pair = AdjListTypeToOrderedAligned(adj_list_type); + adj_list_node["ordered"] = pair.first ? "true" : "false"; + adj_list_node["aligned_by"] = pair.second; + adj_list_node["prefix"] = adjacent_list->GetPrefix(); + adj_list_node["file_type"] = + FileTypeToString(adjacent_list->GetFileType()); + node["adj_lists"].PushBack(); + node["adj_lists"][node["adj_lists"].Size() - 1] = adj_list_node; } - pg_node["file_type"] = FileTypeToString(pg->GetFileType()); - for (const auto& p : pg->GetProperties()) { - ::Yaml::Node p_node; - p_node["name"] = p.name; - p_node["data_type"] = p.type->ToTypeName(); - p_node["is_primary"] = p.is_primary ? "true" : "false"; - p_node["is_nullable"] = p.is_nullable ? "true" : "false"; - pg_node["properties"].PushBack(); - pg_node["properties"][pg_node["properties"].Size() - 1] = p_node; + for (const auto& pg : impl_->property_groups_) { + ::Yaml::Node pg_node; + if (!pg->GetPrefix().empty()) { + pg_node["prefix"] = pg->GetPrefix(); + } + pg_node["file_type"] = FileTypeToString(pg->GetFileType()); + for (const auto& p : pg->GetProperties()) { + ::Yaml::Node p_node; + p_node["name"] = p.name; + p_node["data_type"] = p.type->ToTypeName(); + p_node["is_primary"] = p.is_primary ? "true" : "false"; + p_node["is_nullable"] = p.is_nullable ? "true" : "false"; + pg_node["properties"].PushBack(); + pg_node["properties"][pg_node["properties"].Size() - 1] = p_node; + } + node["property_groups"].PushBack(); + node["property_groups"][node["property_groups"].Size() - 1] = pg_node; } - node["property_groups"].PushBack(); - node["property_groups"][node["property_groups"].Size() - 1] = pg_node; - } - if (impl_->version_ != nullptr) { - node["version"] = impl_->version_->ToString(); + if (impl_->version_ != nullptr) { + node["version"] = impl_->version_->ToString(); + } + ::Yaml::Serialize(node, dump_string); + } catch (const std::exception& e) { + return Status::Invalid("Failed to dump edge info: ", e.what()); } - std::string dump_string; - ::Yaml::Serialize(node, dump_string); return dump_string; } @@ -1022,13 +1060,17 @@ class GraphInfo::Impl { version_(std::move(version)), extra_info_(extra_info) { for (size_t i = 0; i < vertex_infos_.size(); i++) { - vlabel_to_index_[vertex_infos_[i]->GetLabel()] = i; + if (vertex_infos_[i] != nullptr) { + vlabel_to_index_[vertex_infos_[i]->GetLabel()] = i; + } } for (size_t i = 0; i < edge_infos_.size(); i++) { - std::string edge_key = ConcatEdgeTriple(edge_infos_[i]->GetSrcLabel(), - edge_infos_[i]->GetEdgeLabel(), - edge_infos_[i]->GetDstLabel()); - elabel_to_index_[edge_key] = i; + if (edge_infos_[i] != nullptr) { + std::string edge_key = ConcatEdgeTriple(edge_infos_[i]->GetSrcLabel(), + edge_infos_[i]->GetEdgeLabel(), + edge_infos_[i]->GetDstLabel()); + elabel_to_index_[edge_key] = i; + } } } @@ -1071,6 +1113,8 @@ GraphInfo::GraphInfo( : impl_(new Impl(graph_name, std::move(vertex_infos), std::move(edge_infos), prefix, version, extra_info)) {} +GraphInfo::~GraphInfo() = default; + const std::string& GraphInfo::GetName() const { return impl_->name_; } const std::string& GraphInfo::GetPrefix() const { return impl_->prefix_; } @@ -1174,6 +1218,9 @@ std::shared_ptr CreateGraphInfo( const EdgeInfoVector& edge_infos, const std::string& prefix, std::shared_ptr version, const std::unordered_map& extra_info) { + if (name.empty()) { + return nullptr; + } return std::make_shared(name, vertex_infos, edge_infos, prefix, version, extra_info); } @@ -1209,37 +1256,41 @@ Result GraphInfo::Dump() const { return Status::Invalid("The graph info is not validated."); } ::Yaml::Node node; - node["name"] = impl_->name_; - node["prefix"] = impl_->prefix_; - node["vertices"]; - node["edges"]; - for (const auto& vertex : GetVertexInfos()) { - node["vertices"].PushBack(); - node["vertices"][node["vertices"].Size() - 1] = - vertex->GetLabel() + ".vertex.yaml"; - } - for (const auto& edge : GetEdgeInfos()) { - node["edges"].PushBack(); - node["edges"][node["edges"].Size() - 1] = - ConcatEdgeTriple(edge->GetSrcLabel(), edge->GetEdgeLabel(), - edge->GetDstLabel()) + - ".edge.yaml"; - } - if (impl_->version_ != nullptr) { - node["version"] = impl_->version_->ToString(); - } - if (impl_->extra_info_.size() > 0) { - node["extra_info"]; - for (const auto& pair : impl_->extra_info_) { - ::Yaml::Node extra_info_node; - extra_info_node["key"] = pair.first; - extra_info_node["value"] = pair.second; - node["extra_info"].PushBack(); - node["extra_info"][node["extra_info"].Size() - 1] = extra_info_node; + std::string dump_string; + try { + node["name"] = impl_->name_; + node["prefix"] = impl_->prefix_; + node["vertices"]; + node["edges"]; + for (const auto& vertex : GetVertexInfos()) { + node["vertices"].PushBack(); + node["vertices"][node["vertices"].Size() - 1] = + vertex->GetLabel() + ".vertex.yaml"; } + for (const auto& edge : GetEdgeInfos()) { + node["edges"].PushBack(); + node["edges"][node["edges"].Size() - 1] = + ConcatEdgeTriple(edge->GetSrcLabel(), edge->GetEdgeLabel(), + edge->GetDstLabel()) + + ".edge.yaml"; + } + if (impl_->version_ != nullptr) { + node["version"] = impl_->version_->ToString(); + } + if (impl_->extra_info_.size() > 0) { + node["extra_info"]; + for (const auto& pair : impl_->extra_info_) { + ::Yaml::Node extra_info_node; + extra_info_node["key"] = pair.first; + extra_info_node["value"] = pair.second; + node["extra_info"].PushBack(); + node["extra_info"][node["extra_info"].Size() - 1] = extra_info_node; + } + } + ::Yaml::Serialize(node, dump_string); + } catch (const std::exception& e) { + return Status::Invalid("Failed to dump graph info: ", e.what()); } - std::string dump_string; - ::Yaml::Serialize(node, dump_string); return dump_string; } diff --git a/cpp/test/test_info.cc b/cpp/test/test_info.cc index d3d0ffec5..764fed2d8 100644 --- a/cpp/test/test_info.cc +++ b/cpp/test/test_info.cc @@ -85,7 +85,6 @@ TEST_CASE("PropertyGroup") { PropertyGroup pg0({p0, p1}, FileType::CSV, "p0_and_p1/"); PropertyGroup pg1({p2, p3, p4}, FileType::PARQUET); - SECTION("Properties") { REQUIRE(pg0.GetProperties().size() == 2); REQUIRE(pg1.GetProperties().size() == 3); @@ -118,15 +117,21 @@ TEST_CASE("PropertyGroup") { PropertyGroup invalid_pg0({invalid_p0}, FileType::CSV); PropertyGroup invalid_pg1({invalid_p1}, FileType::CSV); PropertyGroup invalid_pg2({p0, p0}, FileType::PARQUET); + PropertyGroup invalid_pg3({}, FileType::CSV, "empty/"); REQUIRE(invalid_pg0.IsValidated() == false); REQUIRE(invalid_pg1.IsValidated() == false); REQUIRE(invalid_pg2.IsValidated() == false); + REQUIRE(invalid_pg3.IsValidated() == false); } SECTION("CreatePropertyGroup") { auto pg2 = CreatePropertyGroup({p0, p1}, FileType::CSV, "p0_and_p1/"); REQUIRE(*pg2.get() == pg0); REQUIRE(!(pg0 == pg1)); + + // not allow empty property group + auto pg3 = CreatePropertyGroup({}, FileType::PARQUET); + REQUIRE(pg3 == nullptr); } SECTION("Ostream") { @@ -224,18 +229,25 @@ TEST_CASE("VertexInfo") { auto invalid_vertex_info0 = CreateVertexInfo( label, chunk_size, {invalid_pg}, "test_vertex/", version); REQUIRE(invalid_vertex_info0->IsValidated() == false); - auto invalid_vertex_info1 = - CreateVertexInfo("", chunk_size, {pg}, "test_vertex/", version); - REQUIRE(invalid_vertex_info1->IsValidated() == false); - auto invalid_vertex_info2 = - CreateVertexInfo(label, 0, {pg}, "test_vertex/", version); - REQUIRE(invalid_vertex_info2->IsValidated() == false); + VertexInfo invalid_vertex_info1("", chunk_size, {pg}, "test_vertex/", + version); + REQUIRE(invalid_vertex_info1.IsValidated() == false); + VertexInfo invalid_vertex_info2(label, 0, {pg}, "test_vertex/", version); + REQUIRE(invalid_vertex_info2.IsValidated() == false); // check if prefix empty auto vertex_info_empty_prefix = CreateVertexInfo(label, chunk_size, {pg}, "", version); REQUIRE(vertex_info_empty_prefix->IsValidated() == true); } + SECTION("CreateVertexInfo") { + auto vertex_info3 = CreateVertexInfo("", chunk_size, {pg}, "test_vertex/"); + REQUIRE(vertex_info3 == nullptr); + + auto vertex_info4 = CreateVertexInfo(label, 0, {pg}, "test_vertex/"); + REQUIRE(vertex_info4 == nullptr); + } + SECTION("Dump") { auto dump_result = vertex_info->Dump(); REQUIRE(dump_result.status().ok()); @@ -371,30 +383,23 @@ TEST_CASE("EdgeInfo") { src_chunk_size, dst_chunk_size, directed, {adj_list}, {invalid_pg}, "test_edge/", version); REQUIRE(invalid_edge_info0->IsValidated() == false); - auto invalid_edge_info1 = CreateEdgeInfo( - "", edge_label, dst_label, chunk_size, src_chunk_size, dst_chunk_size, - directed, {adj_list}, {pg}, "test_edge/", version); - REQUIRE(invalid_edge_info1->IsValidated() == false); - auto invalid_edge_info2 = CreateEdgeInfo( - src_label, "", dst_label, chunk_size, src_chunk_size, dst_chunk_size, - directed, {adj_list}, {pg}, "test_edge/", version); - REQUIRE(invalid_edge_info2->IsValidated() == false); - auto invalid_edge_info3 = CreateEdgeInfo( - src_label, edge_label, "", chunk_size, src_chunk_size, dst_chunk_size, - directed, {adj_list}, {pg}, "test_edge/", version); - REQUIRE(invalid_edge_info3->IsValidated() == false); - auto invalid_edge_info4 = CreateEdgeInfo( - src_label, edge_label, dst_label, 0, src_chunk_size, dst_chunk_size, - directed, {adj_list}, {pg}, "test_edge/", version); - REQUIRE(invalid_edge_info4->IsValidated() == false); - auto invalid_edge_info5 = CreateEdgeInfo( - src_label, edge_label, dst_label, chunk_size, 0, dst_chunk_size, - directed, {adj_list}, {pg}, "test_edge/", version); - REQUIRE(invalid_edge_info5->IsValidated() == false); - auto invalid_edge_info6 = CreateEdgeInfo( - src_label, edge_label, dst_label, chunk_size, src_chunk_size, 0, - directed, {adj_list}, {pg}, "test_edge/", version); - REQUIRE(invalid_edge_info6->IsValidated() == false); + for (int i = 0; i < 3; i++) { + std::vector labels = {src_label, edge_label, dst_label}; + labels[i] = ""; + EdgeInfo invalid_edge_info1(labels[0], labels[1], labels[2], chunk_size, + src_chunk_size, dst_chunk_size, directed, + {adj_list}, {pg}, "test_edge/", version); + REQUIRE(invalid_edge_info1.IsValidated() == false); + } + for (int i = 0; i < 3; i++) { + std::vector sizes = {chunk_size, src_chunk_size, dst_chunk_size}; + sizes[i] = 0; + EdgeInfo invalid_edge_info2(src_label, edge_label, dst_label, sizes[0], + sizes[1], sizes[2], directed, {adj_list}, + {pg}, "test_edge/", version); + REQUIRE(invalid_edge_info2.IsValidated() == false); + } + // check if prefix empty auto edge_info_with_empty_prefix = CreateEdgeInfo( src_label, edge_label, dst_label, chunk_size, src_chunk_size, @@ -402,6 +407,29 @@ TEST_CASE("EdgeInfo") { REQUIRE(edge_info_with_empty_prefix->IsValidated() == true); } + SECTION("CreateEdgeInfo") { + for (int i = 0; i < 3; i++) { + std::vector labels = {src_label, edge_label, dst_label}; + labels[i] = ""; + auto edge_info = CreateEdgeInfo( + labels[0], labels[1], labels[2], chunk_size, src_chunk_size, + dst_chunk_size, directed, {adj_list}, {pg}, "test_edge/", version); + REQUIRE(edge_info == nullptr); + } + for (int i = 0; i < 3; i++) { + std::vector sizes = {chunk_size, src_chunk_size, dst_chunk_size}; + sizes[i] = 0; + auto edge_info = CreateEdgeInfo(src_label, edge_label, dst_label, + sizes[0], sizes[1], sizes[2], directed, + {adj_list}, {pg}, "test_edge/", version); + REQUIRE(edge_info == nullptr); + } + auto edge_info_empty_adjlist = CreateEdgeInfo( + src_label, edge_label, dst_label, chunk_size, src_chunk_size, + dst_chunk_size, directed, {}, {pg}, "test_edge/"); + REQUIRE(edge_info_empty_adjlist == nullptr); + } + SECTION("Dump") { auto dump_result = edge_info->Dump(); REQUIRE(dump_result.status().ok()); @@ -433,9 +461,9 @@ src_label: person version: gar/v1 )"; REQUIRE(dump_result.value() == expected); - auto edge_info_empty_version = - CreateEdgeInfo(src_label, edge_label, dst_label, chunk_size, - src_chunk_size, dst_chunk_size, directed, {}, {}); + auto edge_info_empty_version = CreateEdgeInfo( + src_label, edge_label, dst_label, chunk_size, src_chunk_size, + dst_chunk_size, directed, {adj_list}, {pg}); REQUIRE(edge_info_empty_version->Dump().status().ok()); } @@ -553,18 +581,24 @@ TEST_CASE("GraphInfo") { auto invalid_graph_info1 = CreateGraphInfo( name, {vertex_info}, {invalid_edge_info}, "test_graph/", version); REQUIRE(invalid_graph_info1->IsValidated() == false); - auto invalid_graph_info2 = - CreateGraphInfo("", {vertex_info}, {edge_info}, "test_graph/", version); - REQUIRE(invalid_graph_info2->IsValidated() == false); - auto invalid_graph_info3 = - CreateGraphInfo(name, {vertex_info}, {edge_info}, "", version); - REQUIRE(invalid_graph_info3->IsValidated() == false); + GraphInfo invalid_graph_info2("", {vertex_info}, {edge_info}, "test_graph/", + version); + REQUIRE(invalid_graph_info2.IsValidated() == false); + GraphInfo invalid_graph_info3(name, {vertex_info}, {edge_info}, "", + version); + REQUIRE(invalid_graph_info3.IsValidated() == false); // check if prefix empty, graph_info with empty prefix is invalid auto graph_info_with_empty_prefix = CreateGraphInfo(name, {vertex_info}, {edge_info}, "", version); REQUIRE(graph_info_with_empty_prefix->IsValidated() == false); } + SECTION("CreateGraphInfo") { + auto graph_info_empty_name = + CreateGraphInfo("", {vertex_info}, {edge_info}, "test_graph/"); + REQUIRE(graph_info_empty_name == nullptr); + } + SECTION("Dump") { auto dump_result = graph_info->Dump(); REQUIRE(dump_result.status().ok());