All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
kaldi-error-test.cc
Go to the documentation of this file.
1 // base/kaldi-error-test.cc
2 
3 // Copyright 2009-2011 Microsoft Corporation
4 
5 // See ../../COPYING for clarification regarding multiple authors
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16 // MERCHANTABLITY OR NON-INFRINGEMENT.
17 // See the Apache 2 License for the specific language governing permissions and
18 // limitations under the License.
19 
20 
21 #include "base/kaldi-common.h"
22 
23 // testing that we get the stack trace.
24 namespace kaldi {
25 
26 void MyFunction2() {
27  KALDI_ERR << "Ignore this error";
28 }
29 
30 void MyFunction1() {
31  MyFunction2();
32 }
33 
34 void UnitTestError() {
35  {
36  std::cerr << "Ignore next error:\n";
37  MyFunction1();
38  }
39 }
40 
41 
42 } // end namespace kaldi.
43 
44 int main() {
45  kaldi::g_program_name = "/foo/bar/kaldi-error-test";
46  try {
48  KALDI_ASSERT(0); // should not happen.
49  exit(1);
50  } catch(std::runtime_error &r) {
51  std::cout << "UnitTestError: the error we generated was: " << r.what();
52  }
53 }
54 
Relabels neural network egs with the read pdf-id alignments.
Definition: chain.dox:20
void MyFunction1()
const char * g_program_name
This is set by util/parse-options.
Definition: kaldi-error.cc:41
void MyFunction2()
#define KALDI_ERR
Definition: kaldi-error.h:127
void UnitTestError()
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:169
int main()