File: testcase.hpp

package info (click to toggle)
protozero 1.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,548 kB
  • sloc: cpp: 20,364; sh: 18; makefile: 14
file content (21 lines) | stat: -rw-r--r-- 411 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef TESTCASE_HPP
#define TESTCASE_HPP

#include <cassert>
#include <fstream>
#include <limits>
#include <string>

template <class T>
std::string write_to_file(const T& msg, const char* filename) {
    std::string out;

    msg.SerializeToString(&out);
    std::ofstream d{filename, std::ios_base::out|std::ios_base::binary};
    assert(d.is_open());
    d << out;

    return out;
}

#endif // TESTCASE_HPP