~markwright/scalestack/zeromq

« back to all changes in this revision

Viewing changes to ScaleStack/TestCommon.h

  • Committer: Eric Day
  • Date: 2010-02-21 10:36:03 UTC
  • Revision ID: eday@oddments.org-20100221103603-u0agc1fsduqhl728
Initial commit with build system and basic module loading.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Scale Stack
 
3
 *
 
4
 * Copyright (C) 2010 Eric Day (eday@oddments.org)
 
5
 * All rights reserved.
 
6
 *
 
7
 * Use and distribution licensed under the BSD license. See the
 
8
 * COPYING file in the root project directory for full text.
 
9
 */
 
10
 
 
11
/**
 
12
 * @file
 
13
 * @brief Common Declarations and Macros
 
14
 */
 
15
 
 
16
#ifndef SCALESTACK_TESTCOMMON_H
 
17
#define SCALESTACK_TESTCOMMON_H
 
18
 
 
19
#include <assert.h>
 
20
#include <iostream>
 
21
 
 
22
#define TEST_BEGIN(name) \
 
23
static void test_ ## name(void) \
 
24
{ \
 
25
  if (_test_verbose) \
 
26
    std::cout << "  " << #name << "..."; \
 
27
 
 
28
#define TEST_END \
 
29
  if (_test_verbose) \
 
30
    std::cout << "ok" << std::endl; \
 
31
}
 
32
 
 
33
#define TEST_RUNNER_BEGIN(name) \
 
34
int main(int argc, char* argv[]) \
 
35
{ \
 
36
  if (argc == 2 && std::string(argv[1]) == "-v") \
 
37
    _test_verbose = true; \
 
38
  if (_test_verbose) \
 
39
    std::cout << std::endl << #name << std::endl; \
 
40
 
 
41
#define TEST_RUNNER_END \
 
42
  return 0; \
 
43
}
 
44
 
 
45
#define TEST_RUN(name) test_ ## name()
 
46
 
 
47
static bool _test_verbose = false;
 
48
 
 
49
#endif /* SCALESTACK_TESTCOMMON_H */