Newer
Older
/*static std::vector<uint32_t> msgs;
int ftl::net::Socket::send2(uint32_t service, const std::string &data1, const std::string &data2) {
std::cout << "SEND2 (" << service << ")" << std::endl;
ftl::net::Socket::Socket(int s) : disp_(this) {
}
ftl::net::Socket::~Socket() {
}
int ftl::net::Socket::rpcid__ = 0;
int ftl::net::Socket::send(uint32_t service, const std::string &data) {
msgs.push_back(service);
std::cout << "SEND (" << service << ")" << std::endl;
return 0;
}
bool ftl::net::wait() {
return true;
}
std::shared_ptr<ftl::net::Socket> ftl::net::connect(const char *url) {
return nullptr;
}*/
Cluster cluster("ftl://utu.fi", nullptr);
GIVEN( "a valid URI and array datatype" ) {
int data[10];
auto m = cluster.map<int[10]>("ftl://utu.fi/memory/test0", &data);
auto r = cluster.get<int[10]>("ftl://utu.fi/memory/test0");
REQUIRE( r.is_valid() );
REQUIRE( r.size() == 10*sizeof(int) );
REQUIRE( r.is_local() );
}
GIVEN( "a valid URI and invalid data" ) {
auto m = cluster.map<int>("ftl://utu.fi/memory/test0", NULL);
}
GIVEN( "an empty URI" ) {
}
GIVEN( "an invalid URI" ) {
auto m = cluster.map<int>("noschema/test", &data);
}
GIVEN( "an invalid URI schema" ) {
auto m = cluster.map<int>("http://utu.fi/memory/test0", &data);
auto m = cluster.map<int>("ftl://yle.fi/wrong/test0", &data);
}
GIVEN( "a duplicate URI" ) {
auto a = cluster.map<int>("ftl://utu.fi/memory/test0", &data);
auto b = cluster.map<int>("ftl://utu.fi/memory/test0", &data);
}
}
SCENARIO( "Getting a read_ref", "[get]" ) {
Cluster cluster("ftl://utu.fi", nullptr);
auto p = std::make_shared<ftl::net::Socket>(0);
auto m = cluster.map<int>("ftl://utu.fi/memory/test1", &data);
cluster.map<int>("ftl://utu.fi/memory/remote0", &data2);
GIVEN( "a valid URI to local memory" ) {
const auto r = cluster.getReadable<int>("ftl://utu.fi/memory/test1");
REQUIRE( r.is_valid() );
REQUIRE( r.pointer().is_local() );
GIVEN( "a valid URI to remote memory" ) {
const auto r = cluster.getReadable<int>("ftl://utu.fi/memory/remote0");
//REQUIRE( !r.pointer().is_local() );