File: test_minimum.cc

package info (click to toggle)
pstreams 1.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 412 kB
  • sloc: cpp: 1,912; makefile: 126; sh: 18
file content (42 lines) | stat: -rw-r--r-- 859 bytes parent folder | download | duplicates (3)
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
#include "pstream.h"

#include <iostream>

// TODO   abstract process creation and control to a process class.

template class redi::basic_pstreambuf<char>;
template class redi::pstream_common<char>;
template class redi::basic_pstream<char>;
template class redi::basic_ipstream<char>;
template class redi::basic_opstream<char>;
template class redi::basic_rpstream<char>;

int main()
{
    using namespace redi;

    char c;
    ipstream who("id -un");
    if (!(who >> c))
        return 1;

    redi::opstream cat("cat");
    if (!(cat << c))
        return 2;

    while (who >> c)
        cat << c;

    cat << '\n' << peof;

    pstream fail("ghghghg", pstreambuf::pstderr);
    std::string s;
    if (!std::getline(fail, s))
        return 3;
    std::cerr << s << '\n';
    
    rpstream who2("id -un");
    if (!(who2.out() >> c))
        return 4;
}