コード例 #1
0
ファイル: haship.cpp プロジェクト: da2ce7/galaxy42
void addr_is_same(string s1, string s2, bool first_element_was_self_checked=false) {
	auto a1 = c_haship_addr(c_haship_addr::tag_constr_by_addr_dot(), s1);
	auto a2 = c_haship_addr(c_haship_addr::tag_constr_by_addr_dot(), s2);

	EXPECT_EQ(a1,a2);

	if (!first_element_was_self_checked) EXPECT_EQ(a1,a1);
	EXPECT_EQ(a2,a2);
}
コード例 #2
0
ファイル: haship.cpp プロジェクト: da2ce7/galaxy42
void addr_is_invalid(string s1) {
	auto fun1 = [=]() {
		auto a1 = c_haship_addr(c_haship_addr::tag_constr_by_addr_dot(), s1);
		_UNUSED(a1);
	};
	EXPECT_THROW( fun1() , std::invalid_argument);
}
コード例 #3
0
void c_galaxysrv_peers::add_peer_simplestring(const string & simple) {
	_clue("Adding peer from simplestring=" << simple);
	t_peering_reference_parse parse = parse_peer_reference(simple); // partially parsed
	_dbg1("Done the parse itself");
	bool id_anyone=true;
	string id;
	const auto & cables = parse.second;

	auto reference = make_unique<t_peer_reference_newloop>();

	if (parse.first.size()==1) { // there was 1 ID parsed
		_dbg1("There is some ID in that reference.");
		id_anyone=false;
		id = parse.first.at(0);
		reference->hip = c_haship_addr( c_haship_addr::tag_constr_by_addr_dot() , id);
	} else {
		_dbg1("There is NO ID in that reference (anyone?)");
		id_anyone=true;
		_check(parse.first.size() == 0); // else there was no ID parsed
		reference->hip = c_haship_addr::make_empty(); // clear it to be sure
	}
	_note(join_string_sep( id_anyone?"anyone":"id" , id ) );
	_note("Cables: " << cables.size());
	for(const auto & cablestr : cables) {
		_note("Cable: " << cablestr); // cablestr like udp:192.168.1.107:9042
		unique_ptr<c_cable_base_addr> cable_addr = c_cable_base_addr::cable_make_addr( cablestr );
		reference->cable_addr.push_back( std::move(cable_addr) );
	}
	this->add_peer( std::move( reference ) ); // ***
}