File: tests.cc

package info (click to toggle)
libde265 1.0.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,088 kB
  • sloc: cpp: 40,575; sh: 4,184; asm: 1,223; ansic: 368; makefile: 350
file content (100 lines) | stat: -rw-r--r-- 2,207 bytes parent folder | download | duplicates (6)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
 * H.265 video codec.
 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
 *
 * This file is part of libde265.
 *
 * libde265 is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * libde265 is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with libde265.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <stdio.h>
#include <iostream>
#include <string.h>


class Test
{
public:
  Test() { next=s_firstTest; s_firstTest=this; }
  virtual ~Test() { }

  virtual const char* getName() const { return "noname"; }
  virtual const char* getDescription() const { return "no description"; }
  virtual bool work(bool quiet=false) = 0;

  static void runTest(const char* name) {
    Test* t = s_firstTest;
    while (t) {
      if (strcmp(t->getName(), name)==0) {
        t->work();
        break;
      }
      t=t->next;
    }
  }

  static void runAllTests() {
    Test* t = s_firstTest;
    while (t) {
      printf("%s ... ",t->getName());
      fflush(stdout);
      if (t->work(true) == false) {
        printf("*** FAILED ***\n");
      }
      else {
        printf("passed\n");
      }

      t=t->next;
    }
  }

public:
  Test* next;
  static Test* s_firstTest;
};

Test* Test::s_firstTest = NULL;


class ListTests : public Test
{
public:
  const char* getName() const { return "list"; }
  const char* getDescription() const { return "list all available tests"; }
  bool work(bool quiet) {
    if (!quiet) {
      Test* t = s_firstTest;
      while (t) {
        printf("- %s: %s\n",t->getName(), t->getDescription());
        t=t->next;
      }
    }
    return true;
  }
} listtest;



int main(int argc,char** argv)
{
  if (argc>=2) {
    Test::runTest(argv[1]);
  }
  else {
    Test::runAllTests();
  }

  return 0;
}