Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ g++ --version
```

```text
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: x86_64-apple-darwin23.6.0
Apple clang version 17.0.0 (clang-1700.0.13.5)
Target: x86_64-apple-darwin24.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
```
Expand All @@ -189,7 +189,7 @@ cppcheck --version
```

```text
Cppcheck 2.15.0
Cppcheck 2.18.0
```

## Algorithm excersices sources
Expand Down
83 changes: 83 additions & 0 deletions src/tests/unit/documentation/readme_validation.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#include <catch2/catch_test_macros.hpp>
#include <filesystem>
#include <fstream>
#include <string>
#include <regex>

namespace {
std::string readFileContent(const std::string& filepath) {
std::ifstream file(filepath);
if (!file.is_open()) {
throw std::runtime_error("Could not open file: " + filepath);
}

std::string content;
std::string line;
while (std::getline(file, line)) {
content += line + "\n";
}
return content;
}
}

TEST_CASE("README.md contains expected Apple clang version", "[documentation] [readme]") {
std::string readmePath = "README.md";

// Check if file exists
REQUIRE(std::filesystem::exists(readmePath));

std::string content = readFileContent(readmePath);

// Test that the updated Apple clang version is present
REQUIRE(content.find("Apple clang version 17.0.0 (clang-1700.0.13.5)") != std::string::npos);

// Test that the old version is NOT present
REQUIRE(content.find("Apple clang version 15.0.0 (clang-1500.3.9.4)") == std::string::npos);
}

TEST_CASE("README.md contains expected target architecture", "[documentation] [readme]") {
std::string readmePath = "README.md";

// Check if file exists
REQUIRE(std::filesystem::exists(readmePath));

std::string content = readFileContent(readmePath);

// Test that the updated target architecture is present
REQUIRE(content.find("Target: x86_64-apple-darwin24.6.0") != std::string::npos);

// Test that the old target architecture is NOT present
REQUIRE(content.find("Target: x86_64-apple-darwin23.6.0") == std::string::npos);
}

TEST_CASE("README.md contains expected Cppcheck version", "[documentation] [readme]") {
std::string readmePath = "README.md";

// Check if file exists
REQUIRE(std::filesystem::exists(readmePath));

std::string content = readFileContent(readmePath);

// Test that the updated Cppcheck version is present
REQUIRE(content.find("Cppcheck 2.18.0") != std::string::npos);

// Test that the old version is NOT present
REQUIRE(content.find("Cppcheck 2.15.0") == std::string::npos);
}

TEST_CASE("README.md version information format validation", "[documentation] [readme]") {
std::string readmePath = "README.md";

// Check if file exists
REQUIRE(std::filesystem::exists(readmePath));

std::string content = readFileContent(readmePath);

// Validate Apple clang version format using regex
std::regex clang_pattern(R"(Apple clang version \d+\.\d+\.\d+ \(clang-\d+\.\d+\.\d+\.\d+\))");
REQUIRE(std::regex_search(content, clang_pattern));

// Validate Cppcheck version format using regex
std::regex cppcheck_pattern(R"(Cppcheck \d+\.\d+\.\d+)");
REQUIRE(std::regex_search(content, cppcheck_pattern));
}
Loading