unit_test.hpp File Reference

Contains the unit_test class an global unit defines. More...

#include "matador/unit/unit_exception.hpp"
#include <functional>
#include <map>
#include <vector>
#include <string>
#include <sstream>
#include <type_traits>
#include <iostream>
#include <cstring>

Classes

class  matador::unit_test
 A unit_test consists of serveral tests. More...
 

Namespaces

namespace  matador
 The Open Object Store namespace.
 

Macros

#define UNIT_ASSERT_EQUAL(a, b)   assert_equal(a, b, __LINE__, __FILE__)
 Checks if a is equal b.
 
#define UNIT_ASSERT_NOT_EQUAL(a, b)   assert_not_equal(a, b, __LINE__, __FILE__)
 Checks if a is not msgstrequal b.
 
#define UNIT_ASSERT_GREATER(a, b)   assert_greater(a, b, __LINE__, __FILE__)
 Checks if a is greater b.
 
#define UNIT_ASSERT_LESS(a, b)   assert_less(a, b, __LINE__, __FILE__)
 Checks if a is greater b.
 
#define UNIT_ASSERT_FALSE(a)   assert_false(a, __LINE__, __FILE__)
 Checks if a evaluates to false.
 
#define UNIT_ASSERT_TRUE(a)   assert_true(a, __LINE__, __FILE__)
 Checks if a evaluates to true.
 
#define UNIT_ASSERT_NULL(o)   assert_null(o, __LINE__, __FILE__)
 Checks if o is NULL.
 
#define UNIT_ASSERT_NOT_NULL(o)   assert_not_null(o, __LINE__, __FILE__)
 Checks if o is not NULL.
 
#define UNIT_ASSERT_EXCEPTION(expression, exception_type, exception_msg)
 Checks if a is equal b.
 
#define UNIT_EXPECT_EQUAL(a, b)   expect_equal(a, b, __LINE__, __FILE__)
 Checks if a is equal b.
 
#define UNIT_EXPECT_GREATER(a, b)   expect_greater(a, b, __LINE__, __FILE__)
 Checks if a is greater b.
 
#define UNIT_EXPECT_FALSE(a)   expect_false(a, __LINE__, __FILE__)
 Checks if a evaluates to false.
 
#define UNIT_EXPECT_TRUE(a)   expect_true(a, __LINE__, __FILE__)
 Checks if a evaluates to true.
 
#define UNIT_FAIL(msg)
 Throws an error.
 
#define UNIT_WARN(msg)
 Displays a warning.
 
#define UNIT_INFO(msg)   info(msg)
 Displays an informatkon.
 

Detailed Description

Contains the unit_test class an global unit defines.

This file contains the declaration of the unit_test class and the global unit assert defines.

Macro Definition Documentation

◆ UNIT_ASSERT_EQUAL

#define UNIT_ASSERT_EQUAL (   a,
 
)    assert_equal(a, b, __LINE__, __FILE__)

Checks if a is equal b.

If a is not equal b the test method throws a unit_exception with the given message. The exception is caught by the test_suite the message is displayed

◆ UNIT_ASSERT_EXCEPTION

#define UNIT_ASSERT_EXCEPTION (   expression,
  exception_type,
  exception_msg 
)
Value:
do { \
bool exception_caught(false); \
try { \
expression; \
} catch(exception_type &ex) { \
assert_equal(ex.what(), exception_msg, __LINE__, __FILE__); \
exception_caught = true; \
} \
if (!exception_caught) { \
error("expected exception not caught", __LINE__, __FILE__); \
} \
} while(false)

Checks if a is equal b.

If a is not equal b the test method throws a unit_exception with the given message. The exception is caught by the test_suite the message is displayed

◆ UNIT_ASSERT_FALSE

#define UNIT_ASSERT_FALSE (   a)    assert_false(a, __LINE__, __FILE__)

Checks if a evaluates to false.

If a doesn't evaluates to false the test method throws a unit_exception with the given message. The exception is caught by the test_suite the message is displayed

◆ UNIT_ASSERT_GREATER

#define UNIT_ASSERT_GREATER (   a,
 
)    assert_greater(a, b, __LINE__, __FILE__)

Checks if a is greater b.

If a is not greater b the test method throws a unit_exception with the given message. The exception is caught by the test_suite the message is displayed

◆ UNIT_ASSERT_LESS

#define UNIT_ASSERT_LESS (   a,
 
)    assert_less(a, b, __LINE__, __FILE__)

Checks if a is greater b.

If a is not greater b the test method throws a unit_exception with the given message. The exception is caught by the test_suite the message is displayed

◆ UNIT_ASSERT_NOT_EQUAL

#define UNIT_ASSERT_NOT_EQUAL (   a,
 
)    assert_not_equal(a, b, __LINE__, __FILE__)

Checks if a is not msgstrequal b.

If a is equal b the test method throws a unit_exception with the given message. The exception is caught by the test_suite the message is displayed

◆ UNIT_ASSERT_NOT_NULL

#define UNIT_ASSERT_NOT_NULL (   o)    assert_not_null(o, __LINE__, __FILE__)

Checks if o is not NULL.

If o is NULL the test method throws a unit_exception with the given message. The exception is caught by the test_suite the message is displayed

◆ UNIT_ASSERT_NULL

#define UNIT_ASSERT_NULL (   o)    assert_null(o, __LINE__, __FILE__)

Checks if o is NULL.

If o isn't NULL the test method throws a unit_exception with the given message. The exception is caught by the test_suite the message is displayed

◆ UNIT_ASSERT_TRUE

#define UNIT_ASSERT_TRUE (   a)    assert_true(a, __LINE__, __FILE__)

Checks if a evaluates to true.

If a doesn't evaluates to true the test method throws a unit_exception with the given message. The exception is caught by the test_suite the message is displayed

◆ UNIT_EXPECT_EQUAL

#define UNIT_EXPECT_EQUAL (   a,
 
)    expect_equal(a, b, __LINE__, __FILE__)

Checks if a is equal b.

If a is not equal b the test prints the given message to stdout.

◆ UNIT_EXPECT_FALSE

#define UNIT_EXPECT_FALSE (   a)    expect_false(a, __LINE__, __FILE__)

Checks if a evaluates to false.

If a doesn't evaluates to false the test method prints the given message to stdout.

◆ UNIT_EXPECT_GREATER

#define UNIT_EXPECT_GREATER (   a,
 
)    expect_greater(a, b, __LINE__, __FILE__)

Checks if a is greater b.

If a is not greater b the test prints the given message to stdout.

◆ UNIT_EXPECT_TRUE

#define UNIT_EXPECT_TRUE (   a)    expect_true(a, __LINE__, __FILE__)

Checks if a evaluates to true.

If a doesn't evaluates to true the test method prints the given message to stdout.

◆ UNIT_FAIL

#define UNIT_FAIL (   msg)
Value:
do { \
std::stringstream fail_stream; \
fail_stream << msg; \
error(fail_stream.str(), __LINE__, __FILE__);\
} while (false)

Throws an error.

The test method throws an exception with the given error message and the current file and line number information.

◆ UNIT_INFO

#define UNIT_INFO (   msg)    info(msg)

Displays an informatkon.

The test method displays an information with the given message.

◆ UNIT_WARN

#define UNIT_WARN (   msg)
Value:
do { \
std::stringstream warn_stream; \
warn_stream << msg << "\n"; \
warn(warn_stream.str(), __LINE__, __FILE__); \
} while (false)

Displays a warning.

The test method displays a warning with the given message and the current file and line number information.