tests add to namespace sls (#466)

* tests add to namespace sls

* fixed for tests

* finish up namespace sls for tests
This commit is contained in:
Dhanya Thattil
2022-05-23 16:17:32 +02:00
committed by GitHub
parent 8656eeec25
commit d61741c28b
44 changed files with 360 additions and 236 deletions

View File

@ -7,10 +7,12 @@
#include <unistd.h>
#include <vector>
namespace sls {
TEST_CASE("Get size of empty file") {
char fname[] = "temfile_XXXXXX";
std::ifstream ifs(fname);
auto size = sls::getFileSize(ifs);
auto size = getFileSize(ifs);
REQUIRE(size <= 0); // -1 or zero
}
@ -22,7 +24,9 @@ TEST_CASE("Get size of file with data") {
write(fh, data.data(), n_bytes);
std::ifstream ifs(fname);
auto size = sls::getFileSize(ifs);
auto size = getFileSize(ifs);
REQUIRE(size == n_bytes);
REQUIRE(ifs.tellg() == 0); // getting size resets pos!
}
} // namespace sls