MQLUNIT
Macros
MQLUNIT.mqh File Reference

Single include file for the MQLUNIT library. More...

#include "Assert.mqh"
#include "ComparisonCompactor.mqh"
#include "ConsoleTestRunner.mqh"
#include "Constants.mqh"
#include "TerminalTestRunner.mqh"
#include "Test.mqh"
#include "TestCase.mqh"
#include "TestFailure.mqh"
#include "TestResult.mqh"
#include "TestRunner.mqh"
#include "TestSuite.mqh"
#include "TextFileTestRunner.mqh"
#include "XMLTestRunner.mqh"
Include dependency graph for MQLUNIT.mqh:

Macros

#define MQLUNIT_MQLUNIT_MQH
 
#define ASSERT_FAIL(message)
 Fail the test providing a specific failure description. More...
 
#define ASSERT_NULL(message, entity)
 Asserts that the entity is NULL. More...
 
#define ASSERT_NOT_NULL(message, entity)
 Asserts that the entity is not NULL. More...
 
#define ASSERT_TRUE(message, condition)
 Asserts that the boolean condition is true. More...
 
#define ASSERT_FALSE(message, condition)
 Asserts that the boolean condition is false. More...
 
#define ASSERT_EQUALS(message, expected, actual)
 Asserts that the entity actual is equal to the entity expected. More...
 
#define ASSERT_EQUALS_DELTA(message, expected, actual, delta)
 Asserts that the number actual is equal to the entity expected in respect to delta. More...
 
#define MQLUNIT_START
 Starts the MQLUNIT test block definition. More...
 
#define MQLUNIT_INHERIT(super)   super::run(__result__, true);
 Enables running inherited tests from the superclass. More...
 
#define TEST_START(name)
 Defines a beginning of test with a name. More...
 
#define TEST_END
 Defines an end of a test. More...
 
#define MQLUNIT_END
 Ends the MQLUNIT test block definition. More...
 

Detailed Description

Single include file for the MQLUNIT library.

Author
Copyright 2017, Eneset Group Trust

Macro Definition Documentation

◆ ASSERT_EQUALS

#define ASSERT_EQUALS (   message,
  expected,
  actual 
)
Value:
if (!__failed__) { \
string __message__ = MQLUNIT_Assert::assertEquals( \
message, expected, actual \
); \
if (__message__ != NULL) { \
__result__.addFailure( \
&this, __FILE__, __LINE__, __testName__, __message__ \
) \
); \
__failed__ = true; \
} \
}
Record of a failed Test execution.
Definition: TestFailure.mqh:38
static string assertEquals(string message, T &expected, T &actual)
Asserts that two objects are equal. Object are passed by reference. Pointers must be dereferenced to ...

Asserts that the entity actual is equal to the entity expected.

Entities can be values, strings, variables of the primitive types, object references, pointers or arrays of primitive types, object references or pointers.

Note
Enumeration values, function pointers and arrays of enumeration values or function pointers are not supported and will generate an error during the compilation.

◆ ASSERT_EQUALS_DELTA

#define ASSERT_EQUALS_DELTA (   message,
  expected,
  actual,
  delta 
)
Value:
if (!__failed__) { \
string __message__ = MQLUNIT_Assert::assertEqualsDelta( \
message, expected, actual, delta \
); \
if (__message__ != NULL) { \
__result__.addFailure( \
&this, __FILE__, __LINE__, __testName__, __message__ \
) \
); \
__failed__ = true; \
} \
}
static string assertEqualsDelta(string message, double expected, double actual, double delta)
Asserts that two doubles are equal concerning a delta.
Definition: Assert.mqh:224
Record of a failed Test execution.
Definition: TestFailure.mqh:38

Asserts that the number actual is equal to the entity expected in respect to delta.

◆ ASSERT_FAIL

#define ASSERT_FAIL (   message)
Value:
if (!__failed__) { \
string __message__ = MQLUNIT_Assert::fail(message); \
if (__message__ != NULL) { \
__result__.addFailure( \
&this, __FILE__, __LINE__, __testName__, __message__ \
) \
); \
__failed__ = true; \
} \
}
Record of a failed Test execution.
Definition: TestFailure.mqh:38
static string fail()
Fail the test providing a genertc failure description.
Definition: Assert.mqh:162

Fail the test providing a specific failure description.

◆ ASSERT_FALSE

#define ASSERT_FALSE (   message,
  condition 
)
Value:
if (!__failed__) { \
string __message__ = MQLUNIT_Assert::assertFalse(message, condition); \
if (__message__ != NULL) { \
__result__.addFailure( \
&this, __FILE__, __LINE__, __testName__, __message__ \
) \
); \
__failed__ = true; \
} \
}
static string assertFalse(string message, bool condition)
Asserts that the condition is false.
Definition: Assert.mqh:279
Record of a failed Test execution.
Definition: TestFailure.mqh:38

Asserts that the boolean condition is false.

◆ ASSERT_NOT_NULL

#define ASSERT_NOT_NULL (   message,
  entity 
)
Value:
if (!__failed__) { \
string __message__ = MQLUNIT_Assert::assertNotNull(message, entity); \
if (__message__ != NULL) { \
__result__.addFailure( \
&this, __FILE__, __LINE__, __testName__, __message__ \
) \
); \
__failed__ = true; \
} \
}
Record of a failed Test execution.
Definition: TestFailure.mqh:38
static string assertNotNull(string message, T entity)
Asserts that the entity is not NULL. Entity can be a variable of a primitive type, object reference or a pointer.

Asserts that the entity is not NULL.

◆ ASSERT_NULL

#define ASSERT_NULL (   message,
  entity 
)
Value:
if (!__failed__) { \
string __message__ = MQLUNIT_Assert::assertNull(message, entity); \
if (__message__ != NULL) { \
__result__.addFailure( \
&this, __FILE__, __LINE__, __testName__, __message__ \
) \
); \
__failed__ = true; \
} \
}
Record of a failed Test execution.
Definition: TestFailure.mqh:38
static string assertNull(string message, T entity)
Asserts that the entity is NULL. Entity can be a variable of a primitive type, object reference or a ...

Asserts that the entity is NULL.

◆ ASSERT_TRUE

#define ASSERT_TRUE (   message,
  condition 
)
Value:
if (!__failed__) { \
string __message__ = MQLUNIT_Assert::assertTrue(message, condition); \
if (__message__ != NULL) { \
__result__.addFailure( \
&this, __FILE__, __LINE__, __testName__, __message__ \
) \
); \
__failed__ = true; \
} \
}
Record of a failed Test execution.
Definition: TestFailure.mqh:38
static string assertTrue(string message, bool condition)
Asserts that the condition is true.
Definition: Assert.mqh:273

Asserts that the boolean condition is true.

◆ MQLUNIT_END

#define MQLUNIT_END
Value:
if (!__inherit__) { __result__.endSuite(&this); } \
};

Ends the MQLUNIT test block definition.

◆ MQLUNIT_INHERIT

#define MQLUNIT_INHERIT (   super)    super::run(__result__, true);

Enables running inherited tests from the superclass.

◆ MQLUNIT_MQLUNIT_MQH

#define MQLUNIT_MQLUNIT_MQH

◆ MQLUNIT_START

#define MQLUNIT_START
Value:
virtual void run( \
MQLUNIT_TestResult* __result__, bool __inherit__ = false \
) { \
if (!__inherit__) { __result__.startSuite(&this); }
Test result collects the results of executing a test.
Definition: TestResult.mqh:44
void startSuite(MQLUNIT_Test *test)
Test suite started event.
Definition: TestResult.mqh:99

Starts the MQLUNIT test block definition.

◆ TEST_END

#define TEST_END
Value:
; \
__result__.endTest(&this, __testName__); \
tearDown(); \
}

Defines an end of a test.

◆ TEST_START

#define TEST_START (   name)
Value:
{ \
string __testName__ = StringConcatenate("test", #name); \
bool __failed__ = false; \
setUp(); \
__result__.startTest(&this, __testName__);

Defines a beginning of test with a name.


Copyright © 2017 Eneset Group Trust