Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
5ce212fe
There was an error fetching the commit references. Please try again later.
Commit
5ce212fe
authored
6 years ago
by
Nina Džugasová
Browse files
Options
Downloads
Patches
Plain Diff
Added documentation for FileName. More FileNameTests.
parent
75e29571
No related branches found
No related tags found
1 merge request
!15
Nina
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/TNL/FileName.h
+27
-5
27 additions, 5 deletions
src/TNL/FileName.h
src/TNL/String.h
+22
-6
22 additions, 6 deletions
src/TNL/String.h
src/UnitTests/FileNameTest.cpp
+13
-13
13 additions, 13 deletions
src/UnitTests/FileNameTest.cpp
with
62 additions
and
24 deletions
src/TNL/FileName.h
+
27
−
5
View file @
5ce212fe
...
...
@@ -27,17 +27,39 @@ void removeFileExtension( String& file_name );
class
FileName
{
public:
/// \brief Basic constructor.
///
/// Constructs an empty filename object.
FileName
();
/// \brief Sets the base name of given file.
///
/// Sets \e fileNameBase as the base name of given file.
/// @param fileNameBase String that specifies new name of file.
void
setFileNameBase
(
const
String
&
fileNameBase
);
/// \brief Sets the extension of given file.
///
/// Sets \e extension as suffix of a file name.
/// @param extension String that specifies extension of file (without dot). Suffix of a file name. E.g. doc, xls, tnl.
void
setExtension
(
const
String
&
extension
);
// \brief Sets index for given file.
///
/// Sets \e index after the base name of given file.
/// @param index Integer - number of maximum 5(default) digits. (Number of digits can be changed with \c setDigitsCount).
void
setIndex
(
const
int
index
);
// \brief Sets number of digits for index of given file.
///
/// @param digitsCount Integer - number of digits.
void
setDigitsCount
(
const
int
digitsCount
);
/// Creates appropriate name for given file.
///
/// Creates particular file name using \e fileNameBase, \e digitsCount,
/// \e index and \e extension.
String
getFileName
();
protected:
...
...
This diff is collapsed.
Click to expand it.
src/TNL/String.h
+
22
−
6
View file @
5ce212fe
...
...
@@ -39,7 +39,7 @@ class String
/////
/// \brief Basic constructor.
///
/// Constructs an empty string object
with the length of zero characters
.
/// Constructs an empty string object.
String
();
/////
...
...
@@ -88,17 +88,33 @@ class String
/// Returns the number of characters in given string. Equivalent to getSize().
int
getLength
()
const
;
/// Returns the number of characters in given string.
/// \brief Returns the number of characters in given string.
///
/// \par Example
/// \include StringExampleGetSize.cpp
/// \par Output
/// \include StringExampleGetSize.out
int
getSize
()
const
;
/// Returns size of allocated storage for given string.
/// Returns size of allocated storage for given string.
///
/// \par Example
/// \include StringExampleGetAllocatedSize.cpp
/// \par Output
/// \include StringExampleGetAllocatedSize.out
int
getAllocatedSize
()
const
;
/////
/// Reserves space for given \e size.
/// \brief Reserves space for given \e size.
///
/// Requests to allocate storage space of given \e size to avoid memory reallocation.
/// It allocates one more byte for the terminating 0.
/// @param size Number of characters.
///
/// \par Example
/// \include StringExampleSetSize.cpp
/// \par Output
/// \include StringExampleSetSize.out
void
setSize
(
int
size
);
/////
...
...
@@ -186,11 +202,11 @@ class String
/// \brief This function overloads operator=().
///
/// It assigns character
/
e str to this string.
/// It assigns character
\
e str to this string.
String
&
operator
=
(
char
str
);
/// \brief This function overloads operator+=().
///
/// It appends character
/
e str to this string.
/// It appends character
\
e str to this string.
String
&
operator
+=
(
char
str
);
// This function concatenates strings and returns a newly constructed string object.
String
operator
+
(
char
str
)
const
;
...
...
This diff is collapsed.
Click to expand it.
src/UnitTests/FileNameTest.cpp
+
13
−
13
View file @
5ce212fe
...
...
@@ -24,7 +24,7 @@ TEST( FileNameTest, Constructor )
{
FileName
fname
;
EXPECT_EQ
(
strcmp
(
fname
.
getFileName
(),
"00000."
),
0
);
EXPECT_EQ
(
fname
.
getFileName
(),
"00000."
);
}
TEST
(
FileNameTest
,
Base
)
...
...
@@ -32,34 +32,34 @@ TEST( FileNameTest, Base )
FileName
fname
;
fname
.
setFileNameBase
(
"name"
);
EXPECT_EQ
(
strcmp
(
fname
.
getFileName
(),
"name00000."
),
0
);
EXPECT_EQ
(
fname
.
getFileName
(),
"name00000."
);
}
/*
TEST( FileNameTest, Extension )
TEST
(
FileNameTest
,
Extension
)
{
FileName
fname
;
fname
.
setExtension
(
"tnl"
);
EXPECT_EQ(
strcmp(
fname.getFileName(), "00000.tnl"
), 0
);
}
*/
EXPECT_EQ
(
fname
.
getFileName
(),
"00000.tnl"
);
}
/*
TEST( FileNameTest, Index )
TEST
(
FileNameTest
,
Index
)
{
FileName
fname1
;
FileName
fname2
;
fname1
.
setIndex
(
1
);
fname2
.
setIndex
(
50
);
EXPECT_EQ(
strcmp(
fname1.getFileName(), "00001."
), 0
);
EXPECT_EQ(
strcmp(
fname2.getFileName(), "00050."
), 0
);
}
*/
EXPECT_EQ
(
fname1
.
getFileName
(),
"00001."
);
EXPECT_EQ
(
fname2
.
getFileName
(),
"00050."
);
}
/*
TEST( FileNameTest, DigitsCount )
TEST
(
FileNameTest
,
DigitsCount
)
{
FileName
fname
;
fname
.
setDigitsCount
(
4
);
EXPECT_EQ(
strcmp(
fname.getFileName(), "0000."
), 0
);
EXPECT_EQ
(
fname
.
getFileName
(),
"0000."
);
}
TEST
(
FileNameTest
,
AllTogether
)
...
...
@@ -70,8 +70,8 @@ TEST( FileNameTest, AllTogether )
fname
.
setIndex
(
8
);
fname
.
setDigitsCount
(
3
);
EXPECT_EQ(
strcmp(
fname.getFileName(), "name008.tnl"
), 0
);
}
*/
EXPECT_EQ
(
fname
.
getFileName
(),
"name008.tnl"
);
}
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment