Skip to content

Commit

Permalink
Added some unit tests for Driveboard
Browse files Browse the repository at this point in the history
  • Loading branch information
targed committed Feb 1, 2025
1 parent 05b72c2 commit 6d46d31
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 186 deletions.
94 changes: 94 additions & 0 deletions src/IdentitySoftware.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/******************************************************************************
* @brief Implements the IdentitySoftware class.
* Handler for incrementing and tracking software version/build numbers.
*
* @file IdentitySoftware.cpp
* @author Eli Byrd (edbgkk@mst.edu), ClayJay3 (claytonraycowen@gmail.com)
* @date 2023-06-20
*
* @copyright Copyright Mars Rover Design Team 2023 - All Rights Reserved
******************************************************************************/

#include "IdentitySoftware.h"

/******************************************************************************
* @brief Construct a new IdentitySoftware::IdentitySoftware object.
*
*
* @author Eli Byrd (edbgkk@mst.edu), ClayJay3 (claytonraycowen@gmail.com)
* @date 2023-06-20
******************************************************************************/
IdentitySoftware::IdentitySoftware()
{
// Force extra characters to the version numbers for '0' padding
m_szMajorVersion = "000";
m_szMinorVersion = "000";
m_szPatchVersion = "000";
m_szBuildVersion = "000";

// Append the versions after the forced extra characters
m_szMajorVersion += std::to_string(AUTONOMY_MAJOR_VERSION);
m_szMinorVersion += std::to_string(AUTONOMY_MINOR_VERSION);
m_szPatchVersion += std::to_string(AUTONOMY_PATCH_VERSION);
m_szBuildVersion += std::to_string(AUTONOMY_BUILD_VERSION);

// Shorten the strings down to the appropriate lengths
if (m_szMajorVersion.length() > 2)
{
m_szMajorVersion.erase(0, m_szMajorVersion.length() - 2);
}

if (m_szMinorVersion.length() > 2)
{
m_szMinorVersion.erase(0, m_szMinorVersion.length() - 2);
}

if (m_szPatchVersion.length() > 2)
{
m_szPatchVersion.erase(0, m_szPatchVersion.length() - 2);
}

if (m_szBuildVersion.length() > 3)
{
m_szBuildVersion.erase(0, m_szBuildVersion.length() - 3);
}
}

/******************************************************************************
* @brief Gets the version number of project.
*
* @return std::string - The version number.
*
* @author Eli Byrd (edbgkk@mst.edu), ClayJay3 (claytonraycowen@gmail.com)
* @date 2023-06-20
******************************************************************************/
std::string IdentitySoftware::GetVersionNumber()
{
return "v" + m_szMajorVersion + "." + m_szMinorVersion + "." + m_szPatchVersion;
}

/******************************************************************************
* @brief Gets the build number of project.
*
* @return std::string - The build number.
*
* @author Eli Byrd (edbgkk@mst.edu), ClayJay3 (claytonraycowen@gmail.com)
* @date 2023-06-20
******************************************************************************/
std::string IdentitySoftware::GetBuildNumber()
{
return "Build " + m_szBuildVersion;
}

/******************************************************************************
* @brief Gets the combo number container version and build info.
*
* @return std::string - The combo number.
*
* @author Eli Byrd (edbgkk@mst.edu), ClayJay3 (claytonraycowen@gmail.com)
* @date 2023-06-20
******************************************************************************/
std::string IdentitySoftware::GetVersionBuildComboNumber()
{
return "v" + m_szMajorVersion + "." + m_szMinorVersion + "." + m_szPatchVersion + " Build " + m_szBuildVersion;
}
39 changes: 39 additions & 0 deletions src/IdentitySoftware.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/******************************************************************************
* @brief Defines the IdentitySoftware class.
*
* @file IdentitySoftware.h
* @author Eli Byrd (edbgkk@mst.edu), ClayJay3 (claytonraycowen@gmail.com)
* @date 2023-06-20
*
* @copyright Copyright Mars Rover Design Team 2023 - All Rights Reserved
******************************************************************************/

#ifndef IDENTITY_SOFTWARE_H
#define IDENTITY_SOFTWARE_H

/// \cond
#include <string>
/// \endcond

#define AUTONOMY_MAJOR_VERSION 24
#define AUTONOMY_MINOR_VERSION 0
#define AUTONOMY_PATCH_VERSION 0
#define AUTONOMY_BUILD_VERSION 0

class IdentitySoftware
{
private:
std::string m_szMajorVersion;
std::string m_szMinorVersion;
std::string m_szPatchVersion;
std::string m_szBuildVersion;

public:
IdentitySoftware();

std::string GetVersionNumber();
std::string GetBuildNumber();
std::string GetVersionBuildComboNumber();
};

#endif // IDENTITY_SOFTWARE_H
Loading

0 comments on commit 6d46d31

Please sign in to comment.