mt4-unittest icon indicating copy to clipboard operation
mt4-unittest copied to clipboard

'assertEquals' - ambiguous call to overloaded function when using boolean variable

Open femtotrader opened this issue 10 years ago • 1 comments

Hello,

this unittest can't compile

//+------------------------------------------------------------------+
//|                                                test_unittest.mq4 |
//|                                    Copyright © 2014, FemtoTrader |
//|                       https://sites.google.com/site/femtotrader/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2014, FemtoTrader"
#property link      "https://sites.google.com/site/femtotrader/"
#property version   "1.00"
#property strict

#include <UnitTest.mqh>

UnitTest* unittest;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void test_01_assertEquals_bool()
  {
   unittest.addTest(__FUNCTION__);

   bool actual = True;

   unittest.assertEquals(__FUNCTION__,"True should be True",True,actual);
  }

// This is must be false if release version
input bool paramUnitTesting=true;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
   if(paramUnitTesting) 
     {
      unittest=new UnitTest();
     }

   return INIT_SUCCEEDED;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   if(paramUnitTesting) 
     {
      unittest.printSummary();
     }

   delete unittest;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(paramUnitTesting) 
     {
      runAllTests();
     }
  }

void runAllTests()
{
    test_01_assertEquals_bool();
}

I get the following error message.

'assertEquals' - ambiguous call to overloaded function

Kind regards

femtotrader avatar Jun 15 '14 18:06 femtotrader

In fact True (with first letter upper cased) is different from true (with first letter lower cased)... That's strange.

Maybe we should add method such as assertTrue, assertFalse ... (but it doesn't really fix this problem)

bool actual = true;
unittest.assertEquals(__FUNCTION__,"True should be True",true,actual);

Fix this issue

femtotrader avatar Jun 15 '14 18:06 femtotrader