FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
StringNAndBlockStream/BlockStreamTest.cpp at master · AmitSna/StringNAndBlockStream · GitHub
AmitSna
StringNAndBlockStream
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
StringNAndBlockStream
/
BlockStreamTest.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
33 lines (26 loc) · 1017 Bytes
Breadcrumbs
StringNAndBlockStream
/
BlockStreamTest.cpp
Copy path
File metadata and controls
33 lines (26 loc) · 1017 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
/*
BlockStreamTest.cpp
2015-11-09 - 2018-06-30
Esp. Ing. José María Sola
Profesor
UTN FRBA
*/
#
include
"
BlockStream.h
"
#
include
<
cassert
>
int
main
(){
using
Byte =
unsigned
char
;
//
std::byte C++17 #include<cstddef>
struct
Color
{Byte red, green, blue;};
//
A sample block.
constexpr
auto
filename{
"
color.bin
"
};
//
Write
std::ofstream out{filename, std::ios::binary};
//
Create and connect to write.
WriteBlock
(out, Color{
70
,
130
,
180
});
//
Write to out.
out.
close
();
//
Disconnect.
//
Read
std::ifstream in{filename, std::ios::binary};
//
Connect to read.
Color steelBlue;
//
Object to store read data.
ReadBlock
(in, steelBlue);
//
Read from in.
in.
close
();
//
Disconcect.
remove
(filename);
//
C++17 // std::filesystem::remove(filename);
//
Test
assert
(
70
== steelBlue.
red
);
assert
(
130
== steelBlue.
green
);
assert
(
180
== steelBlue.
blue
);
}
Back
|
FazBrowse Home
|
New Git URL