File: test-context.h

package info (click to toggle)
opentype-sanitizer 8.2.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,164 kB
  • sloc: cpp: 17,010; makefile: 3
file content (53 lines) | stat: -rw-r--r-- 1,108 bytes parent folder | download | duplicates (15)
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
// Copyright (c) 2014-2015 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef OTS_TEST_CONTEXT_H_
#define OTS_TEST_CONTEXT_H_

#include <cstdarg>

#include "opentype-sanitiser.h"

namespace ots {

class TestContext: public ots::OTSContext {
 public:
  TestContext(int level)
    : level_(level)
  { }

  void Message(int level, const char *format, ...) {
    va_list va;

    if (level > level_)
      return;

    if (level == 0)
      std::fprintf(stderr, "ERROR: ");
    else
      std::fprintf(stderr, "WARNING: ");
    va_start(va, format);
    std::vfprintf(stderr, format, va);
    std::fprintf(stderr, "\n");
    va_end(va);
  }

  ots::TableAction GetTableAction(uint32_t tag) {
    switch (tag) {
      case OTS_TAG('C','B','D','T'):
      case OTS_TAG('C','B','L','C'):
      case OTS_TAG('s','b','i','x'):
        return ots::TABLE_ACTION_PASSTHRU;
      default:
        return ots::TABLE_ACTION_DEFAULT;
    }
  }

private:
  int level_;
};

}  // namespace ots

#endif  // OTS_TEST_CONTEXT_H_