TEST_F(ClientImplementationTest, UUIDToAddressDefaultAndLocalNetwork) { boost::unordered_set<string> local_networks = GetNetworks(); // TODO(mberlin): This effectively requires to run the unit test with at // least one network interface. Put an if around this if this // results into flaky tests. ASSERT_GE(local_networks.size(), 1); AddAddressMapping("*", "default"); AddAddressMapping(*local_networks.begin(), "local-network"); EXPECT_EQ(ExpectedAddress("local-network"), client_->UUIDToAddress(kTestUUID_)); }
int main() { // variables initialization int firstIndex, secondIndex, // used to get substrings prevNet, currentNet, nextNet; // used to get neighbors std::string input, // stores each line of the text file subStr; // the sub string containing numbers // initialize a vector to store the temp network numbers // for each line std::vector<int> tmpNetworks; NetworksList networksList; // create a network list object clock_t t1; t1 = clock(); // read each line until no more input is detected while(getline(std::cin, input) && input != "-1" && input != "") { // find the indexes to use to get a substring FindIndex(input, firstIndex, secondIndex); // get the substring subStr = input.substr(firstIndex, secondIndex); if (DEBUG) { std::cout << "The substring is: " << subStr << std::endl; } // save the numbers tmpNetworks = GetNetworks(subStr); prevNet = 0; // initialize every time currentNet = 0; // initialize every time nextNet = 0; // initialize every time for (int i = 0; i < tmpNetworks.size(); ++i) { currentNet = tmpNetworks[i]; // if is not the last number in the temp vector if (i != tmpNetworks.size() - 1) { nextNet = tmpNetworks[i+1]; } // if else { nextNet = 0; } // else // make sure the networks don't repeat if (currentNet != prevNet) { // creaete a new network object Network *newNet = new Network(tmpNetworks[i]); // input the network number into the networksList networksList.InsertNetwork(*newNet); if (DEBUG) { std::cout << "last net num:" << tmpNetworks[i] << std::endl; } // since the neighbor to be entered will be to the last network // of the vector, we use that to our advantage // insert neighbors into the network if (prevNet != 0) { networksList.InsertNeighbor(tmpNetworks[i], prevNet); } if (nextNet != 0) { networksList.InsertNeighbor(tmpNetworks[i], nextNet); } // dealocate memory delete newNet; } // in case that the networks repeat else if (currentNet != nextNet) { if (nextNet != 0) { networksList.InsertNeighbor(tmpNetworks[i], nextNet); } } if (DEBUG) { std::cout << "Network " << i+1 << ": " << tmpNetworks[i] << std::endl; std::cout << "PrevNet:" << prevNet << "\nCurrNet:" << currentNet << "\nNextNEt:" << nextNet << std::endl; } // maintain sanity prevNet = currentNet; } // for } // while networksList.SortNetworks(); for (int ntwrk = 0; ntwrk < networksList.GetNumNetworks(); ++ntwrk) { networksList.PrintNetwork(ntwrk); } clock_t t2 = clock(); double clockDiff = ((double)t2 - (double)t1) / CLOCKS_PER_SEC; if (DEBUG_TIME) { std::cout << "Execution time: " << clockDiff << " seconds" << std::endl; } return 0; }