How to test functions without any parameters

Mnksh
2012-07-03
2012-11-06
  • Mnksh

    Mnksh - 2012-07-03

    Hello,

    Say, I have a boolean function which returns a true or false without any
    parameters.

    bool SomeFunction( void )
    {
      int size = 200;
      if( size < 0 )
        return false;
      if( size > 200 )
        return false;
      if( size == 200 )
        return true
    

    ;
    }

    For the above function, I have 3 paths or 3 conditions. How could I test the
    above SomeFunction() using CUnit assertions? Please help.

    Thanks!

     
    • sawi

      sawi - 2012-11-06

      hi Mnksh,
      as far as I can see the function has just one path since size is fixed to 200. a compiler would throw away the rest.

      thats why there is no need to test this function in different ways, just

      CU_ASSERT_EQUAL(SomeFunction,true);

      cya

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks