Skip to content

Commit

Permalink
[io] adjust RRawFile/XRootD unit test to new target
Browse files Browse the repository at this point in the history
  • Loading branch information
jblomer committed Nov 16, 2023
1 parent 1b8c060 commit 18b789c
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions net/netxng/test/RRawFileNetXNG.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "ROOT/RRawFileNetXNG.hxx"

#include <string>
#include <utility>

#include "gtest/gtest.h"

Expand All @@ -12,19 +13,19 @@ TEST(RRawFileNetXNG, Idle)
{
// Test construction and destruction if the URL is never opened
RRawFile::ROptions options;
RRawFileNetXNG("root://eospublic.cern.ch//eos/root-eos/xrootd.test", options);
RRawFileNetXNG("root://eospublic.cern.ch//eos/root-eos/testfiles/xrootd.test", options);
}

TEST(RRawFileNetXNG, Basics)
{
std::string line;
RRawFile::ROptions options;
std::unique_ptr<RRawFileNetXNG> f(new RRawFileNetXNG("root://eospublic.cern.ch//eos/root-eos/xrootd.test", options));
auto f = std::make_unique<RRawFileNetXNG>("root://eospublic.cern.ch//eos/root-eos/testfiles/xrootd.test", options);
f->Readln(line);
EXPECT_STREQ("Hello, World", line.c_str());
EXPECT_EQ(13u, f->GetSize());
EXPECT_STREQ("This file is used in the RRawFile unit tests", line.c_str());
EXPECT_EQ(45u, f->GetSize());

std::unique_ptr<RRawFileNetXNG> f2(new RRawFileNetXNG("root://eospublic.cern.ch//eos/root-eos/xrootd.test.ENOENT", options));
auto f2 = std::make_unique<RRawFileNetXNG>("root://eospublic.cern.ch//eos/root-eos/testfiles/xrootd.NOENT", options);
EXPECT_THROW(f2->Readln(line), std::runtime_error);
}

Expand All @@ -34,18 +35,18 @@ TEST(RRawFileNetXNG, Eof)
char tail[4];
tail[3] = '\0';
RRawFile::ROptions options;
std::unique_ptr<RRawFileNetXNG> f(new RRawFileNetXNG("root://eospublic.cern.ch//eos/root-eos/xrootd.test", options));
auto f = std::make_unique<RRawFileNetXNG>("root://eospublic.cern.ch//eos/root-eos/testfiles/xrootd.test", options);
auto nbytes = f->ReadAt(tail, 10, f->GetSize() - 3);
EXPECT_EQ(3u, nbytes);
EXPECT_STREQ("ld\n", tail);
EXPECT_STREQ("ts\n", tail);
}


TEST(RRawFileNetXNG, ReadV)
{
RRawFile::ROptions options;
options.fBlockSize = 0;
std::unique_ptr<RRawFileNetXNG> f(new RRawFileNetXNG("root://eospublic.cern.ch//eos/root-eos/xrootd.test", options));
auto f = std::make_unique<RRawFileNetXNG>("root://eospublic.cern.ch//eos/root-eos/testfiles/xrootd.test", options);

char buffer[2];
buffer[0] = buffer[1] = 0;
Expand All @@ -54,12 +55,12 @@ TEST(RRawFileNetXNG, ReadV)
iovec[0].fOffset = 0;
iovec[0].fSize = 1;
iovec[1].fBuffer = &buffer[1];
iovec[1].fOffset = 11;
iovec[1].fOffset = 43;
iovec[1].fSize = 1;
f->ReadV(iovec, 2);

EXPECT_EQ(1U, iovec[0].fOutBytes);
EXPECT_EQ(1U, iovec[1].fOutBytes);
EXPECT_EQ('H', buffer[0]);
EXPECT_EQ('d', buffer[1]);
EXPECT_EQ('T', buffer[0]);
EXPECT_EQ('s', buffer[1]);
}

0 comments on commit 18b789c

Please sign in to comment.