mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [
git repo
]
fileUtils_test.cpp
Go to the documentation of this file.
1
/** \file fileUtils_test.cpp
2
*/
3
#include "../../catch2/catch.hpp"
4
5
6
#define MX_NO_ERROR_REPORTS
7
8
#include "../../../include/ioutils/fileUtils.hpp"
9
10
/** Verify creation of sequential file names
11
*
12
* \anchor tests_ioutils_fileUtils_getSequentialFilename
13
*/
14
SCENARIO
(
"creating sequential filenames"
,
"[ioutils::fileUtils]"
)
15
{
16
GIVEN(
"a varying numbers of digits desired"
)
17
{
18
WHEN(
"default 4 digits, starting at 0"
)
19
{
20
std::string fname =
mx::ioutils::getSequentialFilename
(
"base"
,
".test"
);
21
REQUIRE(fname ==
"base0000.test"
);
22
}
23
24
WHEN(
"default 4 digits, starting at 1"
)
25
{
26
std::string fname =
mx::ioutils::getSequentialFilename
(
"base"
,
".test"
, 1);
27
REQUIRE(fname ==
"base0001.test"
);
28
}
29
30
WHEN(
"default 7 digits, starting at 0"
)
31
{
32
std::string fname =
mx::ioutils::getSequentialFilename
(
"base"
,
".test"
,0,7);
33
REQUIRE(fname ==
"base0000000.test"
);
34
}
35
36
WHEN(
"default 7 digits, starting at 1"
)
37
{
38
std::string fname =
mx::ioutils::getSequentialFilename
(
"base"
,
".test"
, 1, 7);
39
REQUIRE(fname ==
"base0000001.test"
);
40
}
41
42
WHEN(
"default 12 digits, starting at 0"
)
43
{
44
std::string fname =
mx::ioutils::getSequentialFilename
(
"base"
,
".test"
,0,12);
45
REQUIRE(fname ==
"base000000000000.test"
);
46
}
47
48
WHEN(
"default 12 digits, starting at 1"
)
49
{
50
std::string fname =
mx::ioutils::getSequentialFilename
(
"base"
,
".test"
, 1, 12);
51
REQUIRE(fname ==
"base000000000001.test"
);
52
}
53
}
54
}
55
56
SCENARIO
SCENARIO("creating sequential filenames", "[ioutils::fileUtils]")
Definition:
fileUtils_test.cpp:14
mx::ioutils::getSequentialFilename
std::string getSequentialFilename(const std::string &basename, const std::string &extension="", const int startat=0, int ndigit=4)
Get the next file in a numbered sequence.
Definition:
fileUtils.cpp:213
tests
include
ioutils
fileUtils_test.cpp
Generated on Sun Nov 26 2023 10:58:12 for mxlib by
1.9.1