File: init.cpp

package info (click to toggle)
mkvtoolnix 97.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 60,284 kB
  • sloc: cpp: 217,034; ruby: 11,453; xml: 8,125; ansic: 6,885; sh: 5,274; python: 1,041; perl: 191; makefile: 113; awk: 16; javascript: 4
file content (51 lines) | stat: -rw-r--r-- 1,119 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
   mkvmerge -- utility for splicing together matroska files
   from component media subtypes

   Distributed under the GPL
   see the file COPYING for details
   or visit https://www.gnu.org/licenses/old-licenses/gpl-2.0.html

   helper functions for unit tests

   Written by Moritz Bunkus <mo@bunkus.online>.
*/

#include "common/common_pch.h"

#include "tests/unit/init.h"

#include "common/hacks.h"
#include "common/unique_numbers.h"

namespace {

void
mxmsg_handler(unsigned int level,
              std::string const &message) {
  if (MXMSG_WARNING == level)
    g_warning_issued = true;

  else if (MXMSG_ERROR == level)
    throw mtxut::mxerror_x{message};
}

}

void
mtxut::init_suite(char const *argv0) {
  clear_list_of_unique_numbers(UNIQUE_ALL_IDS);
  mtx_common_init("UNITTESTS", argv0);

  set_mxmsg_handler(MXMSG_INFO,    mxmsg_handler);
  set_mxmsg_handler(MXMSG_WARNING, mxmsg_handler);
  set_mxmsg_handler(MXMSG_ERROR,   mxmsg_handler);

  mtx::hacks::engage(mtx::hacks::NO_VARIABLE_DATA);
}

void
mtxut::init_case() {
  clear_list_of_unique_numbers(UNIQUE_ALL_IDS);
  g_warning_issued = false;
}