tests add to namespace sls (#464)

This commit is contained in:
Dhanya Thattil
2022-05-20 15:41:37 +02:00
committed by GitHub
parent c7ba79644a
commit f5745fcf18
44 changed files with 350 additions and 228 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