From e3f6c57ce36fab5e6ab51e305ccdf58c0ac5e495 Mon Sep 17 00:00:00 2001
From: Nina Dzugasova <dzugasova.nina@gmail.com>
Date: Tue, 6 Nov 2018 15:04:20 +0100
Subject: [PATCH] Added documentation for FileName. More FileNameTests.

---
 src/TNL/FileName.h             | 31 +++++++++++++++++++++++++++----
 src/TNL/String.h               | 29 +++++++++++++++++++++++------
 src/UnitTests/FileNameTest.cpp | 22 +++++++++++-----------
 3 files changed, 61 insertions(+), 21 deletions(-)

diff --git a/src/TNL/FileName.h b/src/TNL/FileName.h
index ddf7c78d3a..adb9ce88d9 100644
--- a/src/TNL/FileName.h
+++ b/src/TNL/FileName.h
@@ -21,7 +21,10 @@ void removeFileExtension( String& file_name );
 class FileName
 {
    public:
-      
+
+      /// \brief Basic constructor.
+      ///
+      /// Constructs an empty filename object.
       FileName();
       
       FileName( const String& fileNameBase );
@@ -29,12 +32,28 @@ class FileName
       FileName( const String& fileNameBase, 
                 const String& extension );
       
+
+      /// \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 );
       
       void setDistributedSystemNodeId( int nodeId );
@@ -42,6 +61,10 @@ class FileName
       template< typename Coordinates >
       void setDistributedSystemNodeId( const Coordinates& nodeId );
       
+      /// Creates appropriate name for given file.
+      /// 
+      /// Creates particular file name using \e fileNameBase, \e digitsCount,
+      /// \e index and \e extension.
       String getFileName();
       
    protected:
diff --git a/src/TNL/String.h b/src/TNL/String.h
index 6b77d12f4c..b18e784a63 100644
--- a/src/TNL/String.h
+++ b/src/TNL/String.h
@@ -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();
 
       /////
@@ -83,17 +83,34 @@ class String
 
       /// Returns the number of characters in given string. Equivalent to \c 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 );
 
       /////
@@ -181,11 +198,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;
diff --git a/src/UnitTests/FileNameTest.cpp b/src/UnitTests/FileNameTest.cpp
index 134a5f56a7..8819b609ce 100644
--- a/src/UnitTests/FileNameTest.cpp
+++ b/src/UnitTests/FileNameTest.cpp
@@ -35,31 +35,31 @@ TEST( FileNameTest, Base )
     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
 
 
-- 
GitLab