Пример #1
0
/*
 * This is the main that drives running
 * unit tests.
 */
int main(int argc, char** argv) {
    //Load the test map
    std::string map_name = "/cad2/ece297s/public/maps/toronto.bin";
    if(!load_map(map_name)) {
        std::cout << "ERROR: Could not load map file: '" << map_name << "'!";
        std::cout << " Subsequent tests will likely fail." << std::endl;
        //Don't abort tests, since we still want to show that all
        //tests fail.
    }

    //Run the unit tests
    int num_failures = UnitTest::RunAllTests();

    //Cleanup
    close_map();

    return num_failures;
}
Пример #2
0
/*
 * This is the main that drives running
 * unit tests.
 */
int main(int argc, char** argv) {
    //Load the test map
    std::string map_name = "mapper/Maps/toronto.streets.bin";
    if(!load_map(map_name)) {
        std::cout << "ERROR: Could not load map file: '" << map_name << "'!";
        std::cout << " Subsequent tests will likely fail." << std::endl;
        std::cout << "A common cause of this error is that the relative file location mapper/Maps/toronto.streets.bin is not valid for where you are launching this executable from." << std::endl;
        //Don't abort tests, since we still want to show that all
        //tests fail.
    }


    //Run the unit tests
    int num_failures = UnitTest::RunAllTests();

    //Cleanup
    close_map();

    return num_failures;
}
static struct so_list *
osf_current_sos (void)
{
  struct so_list *head = NULL, *tail, *newtail, so;
  struct read_map_ctxt ctxt;
  int skipped_main;

  if (!open_map (&ctxt))
    return NULL;

  /* Read subsequent elements.  */
  for (skipped_main = 0;;)
    {
      if (!read_map (&ctxt, &so))
	break;

      /* Skip the main program module, which is first in the list after
         /sbin/loader.  */
      if (!so.lm_info->isloader && !skipped_main)
	{
	  osf_free_so (&so);
	  skipped_main = 1;
	  continue;
	}

      newtail = xmalloc (sizeof *newtail);
      if (!head)
	head = newtail;
      else
	tail->next = newtail;
      tail = newtail;

      memcpy (tail, &so, sizeof so);
      tail->next = NULL;
    }

  close_map (&ctxt);
  return head;
}
Пример #4
0
void parsing(){
    std::cout << "================================================================================" << std::endl;
    std::cout << "                        ECE297: Communication and Design                        " << std::endl;
    std::cout << "                                  TEAM CD025                                    " << std::endl; 
    std::cout << "--------------------------------------------------------------------------------" << std::endl;
    std::cout << "Welcome to team cd025's map (Revision 81).                                      " << std::endl;
    std::cout << "Type in 'help' for a list of available commands.                                " << std::endl;
    std::cout << "================================================================================" << std::endl;
    
    
    
    select_map();

    setup();

    char* buffer;
    rl_completer_quote_characters = strdup("\"\'");
    char* breakSet = "\t\n;";
    rl_completer_word_break_characters = breakSet;
    rl_bind_key('\t', rl_complete);
    
    init_graphics("Team CD025 Mapper", CFG_background);
    
    create_button("Window", "POI", toggle_poi);
    create_button("POI", "Land", toggle_natural); 
    create_button("Land", "Waterways", toggle_waterways); 
    create_button("Waterways", "Boundaries", toggle_boundary); 
    create_button("Boundaries", "Water", toggle_water); 
    create_button("Water", "Parks", toggle_parks);
    
    create_button("Parks", "Night Mode", Night_mode); //changes the background to black
    draw_map();
    

    
    std::cout << "Type in 'help' for a list of commands." << std::endl;
        
    while((buffer = readline("mapper> ")) != NULL ){
        GVAR_draw_tsp_points = false;
        GVAR_depotIDs.clear();
        GVAR_deliveryIDs.clear();
        
        if(strcmp(buffer, "") != 0){
            add_history(buffer);
        }
        
        if(!(strcmp(buffer, "Exit")) || !(strcmp(buffer, "quit")) ||!(strcmp(buffer, "exit"))){
            close_graphics();
            close_map();
            
            break;
        } else if(!(strcmp(buffer, "change"))){
            close_map();
            
            select_map();
            setup();
            
        } else if(!(strcmp(buffer, "tsp")) || !(strcmp(buffer, "ts")) ||!(strcmp(buffer, "Traveling_Salesman"))){
            // Try creating buffer, initializing string and then freeing buffer to get rid of memory leaks
            std::string depotPoints(readline("Enter delivery intersection IDs (Space separated):"));
            char* numSep = strtok((char*)(depotPoints.c_str()), " ");
            
            while (numSep != NULL){
                std::stringstream strValue;
                strValue << numSep;
                unsigned intersection;
                strValue >> intersection;
                GVAR_depotIDs.push_back(intersection);
                numSep = strtok (NULL, " ");
            }
            
            std::string deliveryPoints(readline("Enter depot intersection IDs (Space separated):"));
            numSep = strtok((char*)(deliveryPoints.c_str()), " ");
            
            while (numSep != NULL){
                std::stringstream strValue;
                strValue << numSep;
                unsigned intersection;
                strValue >> intersection;
                GVAR_deliveryIDs.push_back(intersection);
                numSep = strtok (NULL, " ");
            }
            std::cout << "Calculating optimal path..." << std::endl;
            GVAR_path = traveling_salesman(GVAR_depotIDs, GVAR_deliveryIDs);
            if(GVAR_path.empty()){
                std::cout << "No valid path exists" << std::endl;
            } else {
                
                GVAR_mypath = Path(0,0, GVAR_path);
                GVAR_mypath.setistour(true);
                std::cout << "Path found and drawn!" << std::endl;
                GVAR_draw_tsp_points = true;
            }
            draw_map();
        } else if(!(strcmp(buffer, "draw"))){