mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [
git repo
]
Loading...
Searching...
No Matches
fileUtils_test.cpp
Go to the documentation of this file.
1
/** \file fileUtils_test.cpp
2
*/
3
#include "../../catch2/catch.hpp"
4
5
#define MX_NO_ERROR_REPORTS
6
7
#include "../../../include/ioutils/fileUtils.hpp"
8
9
/** Verify creation of sequential file names
10
*
11
* \anchor tests_ioutils_fileUtils_getSequentialFilename
12
*/
13
SCENARIO
(
"creating sequential filenames"
,
"[ioutils::fileUtils]"
)
14
{
15
GIVEN(
"a varying numbers of digits desired"
)
16
{
17
WHEN(
"default 4 digits, starting at 0"
)
18
{
19
std::string fname =
mx::ioutils::getSequentialFilename
(
"base"
,
".test"
);
20
REQUIRE( fname ==
"base0000.test"
);
21
}
22
23
WHEN(
"default 4 digits, starting at 1"
)
24
{
25
std::string fname =
mx::ioutils::getSequentialFilename
(
"base"
,
".test"
, 1 );
26
REQUIRE( fname ==
"base0001.test"
);
27
}
28
29
WHEN(
"default 7 digits, starting at 0"
)
30
{
31
std::string fname =
mx::ioutils::getSequentialFilename
(
"base"
,
".test"
, 0, 7 );
32
REQUIRE( fname ==
"base0000000.test"
);
33
}
34
35
WHEN(
"default 7 digits, starting at 1"
)
36
{
37
std::string fname =
mx::ioutils::getSequentialFilename
(
"base"
,
".test"
, 1, 7 );
38
REQUIRE( fname ==
"base0000001.test"
);
39
}
40
41
WHEN(
"default 12 digits, starting at 0"
)
42
{
43
std::string fname =
mx::ioutils::getSequentialFilename
(
"base"
,
".test"
, 0, 12 );
44
REQUIRE( fname ==
"base000000000000.test"
);
45
}
46
47
WHEN(
"default 12 digits, starting at 1"
)
48
{
49
std::string fname =
mx::ioutils::getSequentialFilename
(
"base"
,
".test"
, 1, 12 );
50
REQUIRE( fname ==
"base000000000001.test"
);
51
}
52
}
53
}
SCENARIO
SCENARIO("creating sequential filenames", "[ioutils::fileUtils]")
Definition
fileUtils_test.cpp:13
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:265
tests
include
ioutils
fileUtils_test.cpp
Generated on Wed Mar 5 2025 10:09:16 for mxlib by
1.9.8