Coverage Report

Created: 2025-07-12 06:46

/src/brunsli/c/tests/test_utils.h
Line
Count
Source
1
// Copyright (c) Google LLC 2019
2
//
3
// Use of this source code is governed by an MIT-style
4
// license that can be found in the LICENSE file or at
5
// https://opensource.org/licenses/MIT.
6
7
#ifndef BRUNSLI_TESTS_TEST_UTILS_H_
8
#define BRUNSLI_TESTS_TEST_UTILS_H_
9
10
#include <cstdint>
11
#include <cstddef>
12
#include <string>
13
#include <tuple>
14
#include <vector>
15
16
namespace brunsli {
17
18
/**
19
 * Output callback for JPEGOutput.
20
 *
21
 * assert(data instanceof std::string)
22
 */
23
size_t StringOutputFunction(void* data, const uint8_t* buf, size_t count);
24
25
std::vector<uint8_t> GetSmallBrunsliFile();
26
const size_t kSmallBrunsliSignatuteSize = 6;
27
const size_t kSmallBrunsliHeaderSize = 10;
28
29
std::vector<uint8_t> GetFallbackBrunsliFile();
30
31
std::vector<std::tuple<std::vector<uint8_t>>> ParseMar(const void* data,
32
                                                             size_t size);
33
34
std::vector<uint8_t> ReadTestData(const std::string& filename);
35
36
}  // namespace brunsli
37
38
#if !defined(TEST)
39
#define TEST(A, B)    \
40
  class A##B##_Test { \
41
   private:           \
42
    void TestBody();  \
43
  };                  \
44
  void A##B##_Test::TestBody()
45
#endif
46
47
#if !defined(FUZZ_TEST)
48
struct FuzzTestSink {
49
  template<typename F>
50
2
  FuzzTestSink WithSeeds(F) {
51
2
    return *this;
52
2
  }
53
};
54
#define FUZZ_TEST(A, B) \
55
  const FuzzTestSink unused##A##B = FuzzTestSink()
56
#endif
57
58
#endif  // BRUNSLI_TESTS_TEST_UTILS_H_