stream: using namespace in UnitTests
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
34449d124d
commit
e7b6ab5345
@ -6,6 +6,8 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace stdex;
|
||||||
|
using namespace stdex::stream;
|
||||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||||
|
|
||||||
namespace UnitTests
|
namespace UnitTests
|
||||||
@ -16,17 +18,17 @@ namespace UnitTests
|
|||||||
TEST_METHOD(async)
|
TEST_METHOD(async)
|
||||||
{
|
{
|
||||||
constexpr size_t total = 1000;
|
constexpr size_t total = 1000;
|
||||||
stdex::stream::memory_file source(stdex::mul(total, sizeof(size_t)));
|
memory_file source(mul(total, sizeof(size_t)));
|
||||||
{
|
{
|
||||||
stdex::stream::async_writer<70> writer(source);
|
async_writer<70> writer(source);
|
||||||
for (size_t i = 0; i < total; ++i) {
|
for (size_t i = 0; i < total; ++i) {
|
||||||
Assert::IsTrue(writer.ok());
|
Assert::IsTrue(writer.ok());
|
||||||
writer << i;
|
writer << i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Assert::AreEqual<fpos_t>(0, source.seekbeg(0));
|
Assert::AreEqual<stdex::stream::fpos_t>(0, source.seekbeg(0));
|
||||||
{
|
{
|
||||||
stdex::stream::async_reader<50> reader(source);
|
async_reader<50> reader(source);
|
||||||
size_t x;
|
size_t x;
|
||||||
for (size_t i = 0; i < total; ++i) {
|
for (size_t i = 0; i < total; ++i) {
|
||||||
reader >> x;
|
reader >> x;
|
||||||
@ -42,32 +44,24 @@ namespace UnitTests
|
|||||||
{
|
{
|
||||||
constexpr size_t total = 1000;
|
constexpr size_t total = 1000;
|
||||||
|
|
||||||
stdex::stream::memory_file f1(stdex::mul(total, sizeof(size_t)));
|
memory_file f1(mul(total, sizeof(size_t)));
|
||||||
|
|
||||||
std::basic_string<stdex::sys_char> filename2, filename3;
|
sys_string filename2, filename3;
|
||||||
#ifdef _WIN32
|
filename2 = filename3 = temp_path();
|
||||||
{
|
|
||||||
TCHAR temp_path[MAX_PATH];
|
|
||||||
Assert::IsTrue(ExpandEnvironmentStrings(_T("%TEMP%\\"), temp_path, _countof(temp_path)) < MAX_PATH);
|
|
||||||
filename2 = filename3 = temp_path;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
filename2 = filename3 = "/tmp/";
|
|
||||||
#endif
|
|
||||||
filename2 += _T("stdex-stream-replicator-2.tmp");
|
filename2 += _T("stdex-stream-replicator-2.tmp");
|
||||||
stdex::stream::file f2(
|
file f2(
|
||||||
filename2.c_str(),
|
filename2.c_str(),
|
||||||
stdex::stream::mode_for_reading | stdex::stream::mode_for_writing | stdex::stream::mode_create | stdex::stream::mode_binary);
|
mode_for_reading | mode_for_writing | mode_create | mode_binary);
|
||||||
|
|
||||||
filename3 += _T("stdex-stream-replicator-3.tmp");
|
filename3 += _T("stdex-stream-replicator-3.tmp");
|
||||||
stdex::stream::cached_file f3(
|
cached_file f3(
|
||||||
filename3.c_str(),
|
filename3.c_str(),
|
||||||
stdex::stream::mode_for_reading | stdex::stream::mode_for_writing | stdex::stream::mode_create | stdex::stream::mode_binary,
|
mode_for_reading | mode_for_writing | mode_create | mode_binary,
|
||||||
128);
|
128);
|
||||||
|
|
||||||
{
|
{
|
||||||
stdex::stream::replicator writer;
|
stdex::stream::replicator writer;
|
||||||
stdex::stream::buffer f2_buf(f2, 0, 32);
|
buffer f2_buf(f2, 0, 32);
|
||||||
writer.push_back(&f1);
|
writer.push_back(&f1);
|
||||||
writer.push_back(&f2_buf);
|
writer.push_back(&f2_buf);
|
||||||
writer.push_back(&f3);
|
writer.push_back(&f3);
|
||||||
@ -81,7 +75,7 @@ namespace UnitTests
|
|||||||
f2.seekbeg(0);
|
f2.seekbeg(0);
|
||||||
f3.seekbeg(0);
|
f3.seekbeg(0);
|
||||||
{
|
{
|
||||||
stdex::stream::buffer f2_buf(f2, 64, 0);
|
buffer f2_buf(f2, 64, 0);
|
||||||
size_t x;
|
size_t x;
|
||||||
for (size_t i = 0; i < total; ++i) {
|
for (size_t i = 0; i < total; ++i) {
|
||||||
f1 >> x;
|
f1 >> x;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user