Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6235419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:39:54+00:00 2026-05-24T10:39:54+00:00

How can I convert the following code to use boost unit test framework: #include

  • 0

How can I convert the following code to use boost unit test framework:

#include <iostream>
#include <fstream>

#include "graph.hh"

int main(int argc, char **argv) {
  const char* ifile = argv[1];

  Graph gp;
  gp.read_xml(ifile);

  std::cout << "Checking number of nodes and edges..."  << std::endl;
  int nodes_expected = 16;
  if(nodes_expected != gp.nodes()) {
    std::cout << "Test Failed." << std::endl;
    std::cout << "Expected: " << nodes_expected << std::endl;
    std::cout << "Result: " << gp.nodes() << std::endl;
  }
  int edges_expected = 15;
  if(edges_expected != gp.edges()) {
    std::cout << "Test Failed." << std::endl;
    std::cout << "Expected: " << edges_expected << std::endl;
    std::cout << "Result: " << gp.edges() << std::endl;
  }
  return 0;
}

I’ve read the documentation at (Boost Test), but it doesn’t tell me how to ingest arguments from the command line. Otherwise, I could probably use BOOST_CHECK_EQUAL.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:39:55+00:00Added an answer on May 24, 2026 at 10:39 am
    #include <boost/test/included/unit_test.hpp>
    #include <fstream>
    #include "graph.hh"
    using namespace boost::unit_test;
    
    BOOST_AUTO_TEST_CASE( test_num_of_nodes )
    {
      Graph gp;
      gp.read_xml( framework::master_test_suite().argv[1] );
    
      BOOST_MESSAGE( "Checking number of nodes and edges..." );
    
      BOOST_CHECK_EQUAL(16, gp.nodes());
      BOOST_CHECK_EQUAL(15, gp.edges());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Use following Code for Convert an object value to a decimal.how can i
The following code does not work due to line 4 (can't convert Foo into
Please, look at the following code that just convert an unsigned int to a
Please see the following code: #include <iostream> #include <string> using namespace std; enum dataType
I have the following code and it works fine. #include <boost\mpl\vector.hpp> #include <boost\mpl\fold.hpp> #include
Can someone help me convert the following code into code that instead has two
How can I convert a character to its ASCII code using JavaScript? For example:
I am trying to use the boost generic image library to convert CYMK images
Need to convert the following code from Ruby to C#. However I'm kind of
I am trying to use the following code to write out all processes started

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.