Commit e3f6c57c authored by Nina Džugasová's avatar Nina Džugasová Committed by Tomáš Oberhuber
Browse files

Added documentation for FileName. More FileNameTests.

parent 4b4c6d20
Loading
Loading
Loading
Loading
+27 −4
Original line number Diff line number Diff line
@@ -22,6 +22,9 @@ 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:
+23 −6
Original line number Diff line number Diff line
@@ -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.
      ///
      /// \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;
+11 −11
Original line number Diff line number Diff line
@@ -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