Skip to content
Snippets Groups Projects
Commit 5ce212fe authored by Nina Džugasová's avatar Nina Džugasová
Browse files

Added documentation for FileName. More FileNameTests.

parent 75e29571
No related branches found
No related tags found
1 merge request!15Nina
......@@ -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:
......
......@@ -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;
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment