-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcout-tests.hh
48 lines (40 loc) · 1.14 KB
/
cout-tests.hh
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
#pragma once
#include <gtest/gtest.h>
#include <string>
#include <iostream>
#include "../src/volume-list.hh"
#include "utils_tests.hh"
TEST(cout, cout_empty)
{
auto list = generator();
::testing::internal::CaptureStdout();
std::cout << list;
auto out = ::testing::internal::GetCapturedStdout();
ASSERT_EQ(out, "");
}
TEST(cout, cout_multiple)
{
auto list = generator();
auto elem = std::string("Boring guy");
auto elem1 = std::string("PyBrook");
auto elem2 = std::string("RL_Shooter");
list.append(elem, 10);
list.append(elem1, 10);
list.append(elem2, 10);
::testing::internal::CaptureStdout();
std::cout << list;
auto out = ::testing::internal::GetCapturedStdout();
ASSERT_EQ(out,
"-------[0]-------\n"
"Element: Boring guy\n"
"Position: [0, 9]\n"
"Volume: 10\n"
"-------[1]-------\n"
"Element: PyBrook\n"
"Position: [9, 19]\n"
"Volume: 10\n"
"-------[2]-------\n"
"Element: RL_Shooter\n"
"Position: [19, 29]\n"
"Volume: 10\n");
}