Переглянути джерело

Fixed Version class

- renamed members of Version class, since
identifier where occupied by standard library
- adjusted tests for Version class
Patrick-Laptop 3 роки тому
батько
коміт
13c13aa26e
3 змінених файлів з 56 додано та 56 видалено
  1. 23 23
      source/base/Version.cpp
  2. 11 11
      source/base/Version.hpp
  3. 22 22
      test/cases/base/VersionTest.cpp

+ 23 - 23
source/base/Version.cpp

@@ -3,26 +3,26 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-28
- * Changed:         2020-09-28
+ * Changed:         2020-09-29
  *
  * */
 
 #include <regex>
 #include "Version.hpp"
 
-ls_std::Version::Version(version_type _major, version_type _minor, version_type _patch) :
-major(_major),
-minor(_minor),
-patch(_patch)
+ls_std::Version::Version(version_type _majorVersion, version_type _minorVersion, version_type _patchVersion) :
+majorVersion(_majorVersion),
+minorVersion(_minorVersion),
+patchVersion(_patchVersion)
 {}
 
 ls_std::byte_field ls_std::Version::marshal()
 {
   ls_std::byte_field data {};
 
-  data += std::to_string(this->major) + ".";
-  data += std::to_string(this->minor) + ".";
-  data += std::to_string(this->patch);
+  data += std::to_string(this->majorVersion) + ".";
+  data += std::to_string(this->minorVersion) + ".";
+  data += std::to_string(this->patchVersion);
 
   return data;
 }
@@ -36,31 +36,31 @@ void ls_std::Version::unmarshal(const ls_std::byte_field &_data)
   if(ls_std::Version::_isValid(_data)) {
     position = field.find('.');
     subSequence = field.substr(0, position);
-    this->major = std::stoi(subSequence);
+    this->majorVersion = std::stoi(subSequence);
     field.erase(0, position + 1);
 
     position = field.find('.');
     subSequence = field.substr(0, position);
-    this->minor = std::stoi(subSequence);
+    this->minorVersion = std::stoi(subSequence);
     field.erase(0, position + 1);
 
-    this->patch = std::stoi(field);
+    this->patchVersion = std::stoi(field);
   }
 }
 
-ls_std::version_type ls_std::Version::getMajor() const
+ls_std::version_type ls_std::Version::getMajorVersion() const
 {
-  return this->major;
+  return this->majorVersion;
 }
 
-ls_std::version_type ls_std::Version::getMinor() const
+ls_std::version_type ls_std::Version::getMinorVersion() const
 {
-  return this->minor;
+  return this->minorVersion;
 }
 
-ls_std::version_type ls_std::Version::getPatch() const
+ls_std::version_type ls_std::Version::getPatchVersion() const
 {
-  return this->patch;
+  return this->patchVersion;
 }
 
 bool ls_std::Version::isValid(const std::string &_versionString)
@@ -68,19 +68,19 @@ bool ls_std::Version::isValid(const std::string &_versionString)
   return ls_std::Version::_isValid(_versionString);
 }
 
-void ls_std::Version::setMajor(version_type _major)
+void ls_std::Version::setMajorVersion(version_type _major)
 {
-  this->major = _major;
+  this->majorVersion = _major;
 }
 
-void ls_std::Version::setMinor(version_type _minor)
+void ls_std::Version::setMinorVersion(version_type _minor)
 {
-  this->minor = _minor;
+  this->minorVersion = _minor;
 }
 
-void ls_std::Version::setPatch(version_type _patch)
+void ls_std::Version::setPatchVersion(version_type _patch)
 {
-  this->patch = _patch;
+  this->patchVersion = _patch;
 }
 
 bool ls_std::Version::_isValid(const std::string &_versionString)

+ 11 - 11
source/base/Version.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-27
- * Changed:         2020-09-27
+ * Changed:         2020-09-29
  *
  * */
 
@@ -18,7 +18,7 @@ namespace ls_std {
   class Version : public ISerializable {
     public:
 
-      explicit Version(version_type _major, version_type _minor, version_type _patch);
+      explicit Version(version_type _majorVersion, version_type _minorVersion, version_type _patchVersion);
       ~Version() = default;
 
       // implementation
@@ -28,19 +28,19 @@ namespace ls_std {
 
       // other functionality
 
-      version_type getMajor() const;
-      version_type getMinor() const;
-      version_type getPatch() const;
+      version_type getMajorVersion() const;
+      version_type getMinorVersion() const;
+      version_type getPatchVersion() const;
       static bool isValid(const std::string& _versionString);
-      void setMajor(version_type _major);
-      void setMinor(version_type _minor);
-      void setPatch(version_type _patch);
+      void setMajorVersion(version_type _major);
+      void setMinorVersion(version_type _minor);
+      void setPatchVersion(version_type _patch);
 
     private:
 
-      version_type major {};
-      version_type minor {};
-      version_type patch {};
+      version_type majorVersion {};
+      version_type minorVersion {};
+      version_type patchVersion {};
 
       static bool _isValid(const std::string& _versionString);
   };

+ 22 - 22
test/cases/base/VersionTest.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-28
- * Changed:         2020-09-28
+ * Changed:         2020-09-29
  *
  * */
 
@@ -37,29 +37,29 @@ namespace {
     ls_std::Version version {0, 0, 0};
     version.unmarshal("2020.2.13");
 
-    ASSERT_EQ(2020, version.getMajor());
-    ASSERT_EQ(2, version.getMinor());
-    ASSERT_EQ(13, version.getPatch());
+    ASSERT_EQ(2020, version.getMajorVersion());
+    ASSERT_EQ(2, version.getMinorVersion());
+    ASSERT_EQ(13, version.getPatchVersion());
   }
 
   // other functionality
 
-  TEST_F(VersionTest, getMajor)
+  TEST_F(VersionTest, getMajorVersion)
   {
     ls_std::Version version {13, 2, 4};
-    ASSERT_EQ(13, version.getMajor());
+    ASSERT_EQ(13, version.getMajorVersion());
   }
 
-  TEST_F(VersionTest, getMinor)
+  TEST_F(VersionTest, getMinorVersion)
   {
     ls_std::Version version {13, 2, 4};
-    ASSERT_EQ(2, version.getMinor());
+    ASSERT_EQ(2, version.getMinorVersion());
   }
 
-  TEST_F(VersionTest, getPatch)
+  TEST_F(VersionTest, getPatchVersion)
   {
     ls_std::Version version {13, 2, 4};
-    ASSERT_EQ(4, version.getPatch());
+    ASSERT_EQ(4, version.getPatchVersion());
   }
 
   TEST_F(VersionTest, isValid)
@@ -76,30 +76,30 @@ namespace {
     ASSERT_FALSE(ls_std::Version::isValid("blaaaa"));
   }
 
-  TEST_F(VersionTest, setMajor)
+  TEST_F(VersionTest, setMajorVersion)
   {
     ls_std::Version version {13, 2, 4};
-    ASSERT_EQ(13, version.getMajor());
+    ASSERT_EQ(13, version.getMajorVersion());
 
-    version.setMajor(14);
-    ASSERT_EQ(14, version.getMajor());
+    version.setMajorVersion(14);
+    ASSERT_EQ(14, version.getMajorVersion());
   }
 
-  TEST_F(VersionTest, setMinor)
+  TEST_F(VersionTest, setMinorVersion)
   {
     ls_std::Version version {13, 2, 4};
-    ASSERT_EQ(2, version.getMinor());
+    ASSERT_EQ(2, version.getMinorVersion());
 
-    version.setMinor(3);
-    ASSERT_EQ(3, version.getMinor());
+    version.setMinorVersion(3);
+    ASSERT_EQ(3, version.getMinorVersion());
   }
 
-  TEST_F(VersionTest, setPatch)
+  TEST_F(VersionTest, setPatchVersion)
   {
     ls_std::Version version {13, 2, 4};
-    ASSERT_EQ(4, version.getPatch());
+    ASSERT_EQ(4, version.getPatchVersion());
 
-    version.setPatch(5);
-    ASSERT_EQ(5, version.getPatch());
+    version.setPatchVersion(5);
+    ASSERT_EQ(5, version.getPatchVersion());
   }
 }