~njh-aelius/maxosx/musicbrainz-tags

« back to all changes in this revision

Viewing changes to Frameworks/taglib/taglib/tests/main.cpp

  • Committer: stephen_booth
  • Date: 2008-04-30 01:48:01 UTC
  • Revision ID: svn-v4:6b6cea13-1402-0410-9567-a7afb52bf336:trunk:1371
Fixing the taglib source tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <stdexcept>
2
 
#include <cppunit/TestResult.h>
3
 
#include <cppunit/TestResultCollector.h>
4
 
#include <cppunit/TestRunner.h>
5
 
#include <cppunit/extensions/TestFactoryRegistry.h>
6
 
#include <cppunit/BriefTestProgressListener.h>
7
 
#include <cppunit/CompilerOutputter.h>
8
 
 
9
 
int main(int argc, char* argv[])
10
 
{
11
 
  std::string testPath = (argc > 1) ? std::string(argv[1]) : "";
12
 
 
13
 
  // Create the event manager and test controller
14
 
  CppUnit::TestResult controller;
15
 
 
16
 
  // Add a listener that colllects test result
17
 
  CppUnit::TestResultCollector result;
18
 
  controller.addListener(&result);
19
 
 
20
 
  // Add a listener that print dots as test run.
21
 
  CppUnit::BriefTestProgressListener progress;
22
 
  controller.addListener(&progress);
23
 
 
24
 
  // Add the top suite to the test runner
25
 
  CppUnit::TestRunner runner;
26
 
  runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
27
 
 
28
 
  try {
29
 
    std::cout << "Running "  << testPath;
30
 
    runner.run(controller, testPath);
31
 
 
32
 
    std::cerr << std::endl;
33
 
 
34
 
    // Print test in a compiler compatible format.
35
 
    CppUnit::CompilerOutputter outputter(&result, std::cerr);
36
 
    outputter.write();
37
 
  }
38
 
  catch(std::invalid_argument &e){
39
 
    std::cerr << std::endl
40
 
              << "ERROR: " << e.what()
41
 
              << std::endl;
42
 
    return 0;
43
 
  }
44
 
 
45
 
  return result.wasSuccessful() ? 0 : 1;
46
 
}