mirror of
https://github.com/thunderbrewhq/bc.git
synced 2025-12-12 01:52:30 +00:00
feat(test): add test cases for reading from /dev/zero on UNIX
This commit is contained in:
parent
ee4c39082e
commit
26f3d5527e
1 changed files with 30 additions and 0 deletions
30
test/File.cpp
Normal file
30
test/File.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include "test/Test.hpp"
|
||||
#include "bc/File.hpp"
|
||||
#include "bc/String.hpp"
|
||||
#include "bc/file/Types.hpp"
|
||||
#if defined(WHOA_SYSTEM_LINUX) || defined(WHOA_SYSTEM_MAC)
|
||||
|
||||
TEST_CASE("Blizzard::File::Open", "[file]") {
|
||||
SECTION("open /dev/zero") {
|
||||
Blizzard::File::StreamRecord* file;
|
||||
REQUIRE(Blizzard::File::Open("/dev/zero", Blizzard::File::Mode::mustexist|Blizzard::File::Mode::read, file));
|
||||
REQUIRE(Blizzard::File::Close(file));
|
||||
}
|
||||
|
||||
SECTION("read data from /dev/zero") {
|
||||
Blizzard::File::StreamRecord* file;
|
||||
REQUIRE(Blizzard::File::Open("/dev/zero", Blizzard::File::Mode::mustexist|Blizzard::File::Mode::read, file));
|
||||
|
||||
char zero[1024];
|
||||
char max[1024];
|
||||
Blizzard::String::MemFill(zero, sizeof(zero), 0);
|
||||
Blizzard::String::MemFill(max, sizeof(max), 255);
|
||||
int32_t count = sizeof(zero);
|
||||
REQUIRE(Blizzard::File::Read(file, max, &count));
|
||||
REQUIRE(Blizzard::File::Close(file));
|
||||
REQUIRE(count == sizeof(zero));
|
||||
REQUIRE(Blizzard::String::MemCompare(zero, max, sizeof(zero)) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue