@@ -376,6 +376,66 @@ TEST_CASE_TEMPLATE_DEFINE(
376376
377377 // --- incidence method tests ---
378378
379+ SUBCASE (" bind, unbind and are_incident should throw if either of the fiven elements is invalid"
380+ ) {
381+ sut_type sut{constants::n_vertices, constants::n_hyperedges};
382+
383+ CHECK_THROWS_AS (
384+ sut.bind (constants::out_of_rng_vid, constants::out_of_rng_eid), std::out_of_range
385+ );
386+ CHECK_THROWS_AS (sut.bind (constants::id1, constants::out_of_rng_eid), std::out_of_range);
387+ CHECK_THROWS_AS (sut.bind (constants::out_of_rng_vid, constants::id1), std::out_of_range);
388+
389+ CHECK_THROWS_AS (
390+ sut.unbind (constants::out_of_rng_vid, constants::out_of_rng_eid), std::out_of_range
391+ );
392+ CHECK_THROWS_AS (sut.unbind (constants::id1, constants::out_of_rng_eid), std::out_of_range);
393+ CHECK_THROWS_AS (sut.unbind (constants::out_of_rng_vid, constants::id1), std::out_of_range);
394+
395+ CHECK_THROWS_AS (
396+ static_cast <void >(sut.are_incident (constants::out_of_rng_vid, constants::out_of_rng_eid)
397+ ),
398+ std::out_of_range
399+ );
400+ CHECK_THROWS_AS (
401+ static_cast <void >(sut.are_incident (constants::id1, constants::out_of_rng_eid)),
402+ std::out_of_range
403+ );
404+ CHECK_THROWS_AS (
405+ static_cast <void >(sut.are_incident (constants::out_of_rng_vid, constants::id1)),
406+ std::out_of_range
407+ );
408+ }
409+
410+ SUBCASE (" are_incident should return false by default" ) {
411+ sut_type sut{constants::n_vertices, constants::n_hyperedges};
412+ for (const auto vertex : sut.vertices ())
413+ for (const auto hyperedge : sut.hyperedges ())
414+ CHECK_FALSE (sut.are_incident (vertex, hyperedge));
415+ }
416+
417+ SUBCASE (" bind should properly mark the given vertex and hyperedge as incident and unbind "
418+ " should mark them as not incident" ) {
419+ constexpr auto vertex_id = constants::id1;
420+ constexpr auto hyperedge_id = constants::id2;
421+ constexpr auto unbound_id = constants::id3;
422+
423+ sut_type sut{constants::n_vertices, constants::n_hyperedges};
424+ REQUIRE_FALSE (sut.are_incident (vertex_id, hyperedge_id));
425+ REQUIRE_FALSE (sut.are_incident (vertex_id, unbound_id));
426+ REQUIRE_FALSE (sut.are_incident (unbound_id, hyperedge_id));
427+
428+ sut.bind (vertex_id, hyperedge_id);
429+ CHECK (sut.are_incident (vertex_id, hyperedge_id));
430+ CHECK_FALSE (sut.are_incident (vertex_id, unbound_id));
431+ CHECK_FALSE (sut.are_incident (unbound_id, hyperedge_id));
432+
433+ sut.unbind (vertex_id, hyperedge_id);
434+ CHECK_FALSE (sut.are_incident (vertex_id, hyperedge_id));
435+ CHECK_FALSE (sut.are_incident (vertex_id, unbound_id));
436+ CHECK_FALSE (sut.are_incident (unbound_id, hyperedge_id));
437+ }
438+
379439 SUBCASE (" incident_hyperedges and degree should throw if the given vertex (id) is invalid" ) {
380440 sut_type sut{constants::n_vertices, constants::n_hyperedges};
381441 CHECK_THROWS_AS (
0 commit comments