mirror of https://github.com/oxen-io/lokinet
* add path::Path::UniqueEndpointSet_t
* start using check2 for new unit tests * unit test for path::Path::UniqueEndpointSet_tpull/1091/head
parent
ffa1012049
commit
e35d17764a
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,2 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch.hpp"
|
@ -0,0 +1,39 @@
|
||||
#include <path/path.hpp>
|
||||
#include "catch.hpp"
|
||||
|
||||
using Path_t = llarp::path::Path;
|
||||
using Path_ptr = llarp::path::Path_ptr;
|
||||
using Set_t = llarp::path::Path::UniqueEndpointSet_t;
|
||||
using RC_t = llarp::RouterContact;
|
||||
|
||||
static RC_t
|
||||
MakeHop(const char name)
|
||||
{
|
||||
RC_t rc;
|
||||
rc.pubkey.Fill(name);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Path_ptr
|
||||
MakePath(std::vector< char > hops)
|
||||
{
|
||||
std::vector< RC_t > pathHops;
|
||||
for(const auto& hop : hops)
|
||||
pathHops.push_back(MakeHop(hop));
|
||||
return std::make_shared< Path_t >(pathHops, nullptr, 0);
|
||||
}
|
||||
|
||||
TEST_CASE("UniqueEndpointSet_t has unique endpoints", "[path]")
|
||||
{
|
||||
Set_t set;
|
||||
REQUIRE(set.empty());
|
||||
const auto inserted_first =
|
||||
set.emplace(MakePath({'a', 'b', 'c', 'd'})).second;
|
||||
REQUIRE(inserted_first);
|
||||
const auto inserted_again =
|
||||
set.emplace(MakePath({'a', 'b', 'c', 'd'})).second;
|
||||
REQUIRE(not inserted_again);
|
||||
const auto inserted_second =
|
||||
set.emplace(MakePath({'d', 'c', 'b', 'a'})).second;
|
||||
REQUIRE(inserted_second);
|
||||
}
|
Loading…
Reference in New Issue