Пример #1
0
 REQUIRE(client.getNumClients() == 1);
 REQUIRE(client.stopClients(1));
 REQUIRE(client.getNumClients() == 0);
 REQUIRE_FALSE(client.stopClients(1));
 REQUIRE(client.getNumClients() == 0);
 REQUIRE(client.startClients(1, 1, mockProtocolFactory, mockContentManagerFactory, server));
 REQUIRE(client.getNumClients() == 1);
 REQUIRE(client.startClients(2, 2, mockProtocolFactory, mockContentManagerFactory, server));
 REQUIRE(client.getNumClients() == 2);
 REQUIRE(client.stopClients(1));
 REQUIRE(client.getNumClients() == 1);
 REQUIRE(client.getNumBytesRead() == 0);
 REQUIRE(client.getNumBytesWritten() == 0);
 
 nlohmann::json json = client.toJson();
 REQUIRE(json.size() == 2);
 REQUIRE(json["numClients"].get<unsigned>() == 1);
 REQUIRE(json["workers"].is_object());
 REQUIRE(json["workers"].size() == 1);
 REQUIRE(json["workers"]["2"].is_array());
 REQUIRE(json["workers"]["2"].size() == 2);
 REQUIRE(json["workers"]["2"][0].is_object());
 REQUIRE(json["workers"]["2"][1].is_object());
 
 nlohmann::json json2 = client.toJson(2);
 REQUIRE(json2["found"].get<bool>());
 REQUIRE(json2["worker"].is_array());
 REQUIRE(json2["worker"].size() == 2);
 REQUIRE(json2["worker"][0].is_object());
 REQUIRE(json2["worker"][1].is_object());
 
Пример #2
0
 void from_json(const nlohmann::json &j, Tensor &t) {
     if ( j.size()!=6 || !j.is_array() )
         throw std::runtime_error("Json->Tensor: array w. exactly six coefficients expected.");
     t = Tensor(j[0],j[1],j[2],j[3],j[4],j[5]);
 }