mirror of
https://github.com/szymon-jozef/static-site-generator.git
synced 2026-09-07 12:10:42 +02:00
Added unit testing with Catch2 framework
This commit is contained in:
@@ -3,12 +3,3 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
int main() { return 0; }
|
int main() { return 0; }
|
||||||
|
|
||||||
void test_config_read() {
|
|
||||||
const std::string CONFIG_PATH = "../config/config_example.toml";
|
|
||||||
Config config = get_config(CONFIG_PATH);
|
|
||||||
std::cout << "Config" << std::endl;
|
|
||||||
std::cout << "Author: " << config.contact.author << std::endl;
|
|
||||||
std::cout << "Email: " << config.contact.email << std::endl;
|
|
||||||
std::cout << "Signal: " << config.contact.signal << std::endl;
|
|
||||||
}
|
|
||||||
|
|||||||
11
src/makefile
11
src/makefile
@@ -12,5 +12,14 @@ main.o: main.cpp config.hpp
|
|||||||
config.o: config.cpp config.hpp
|
config.o: config.cpp config.hpp
|
||||||
$(CXX) $(CXXFLAGS) -c config.cpp
|
$(CXX) $(CXXFLAGS) -c config.cpp
|
||||||
|
|
||||||
|
tests: tests.o config.o
|
||||||
|
g++ -std=c++17 -Wall tests.o config.o -o tests -lCatch2Main -lCatch2
|
||||||
|
|
||||||
|
tests.o: tests.cpp config.hpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c tests.cpp
|
||||||
|
|
||||||
|
check: tests
|
||||||
|
./tests
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o blog
|
rm -f *.o blog tests
|
||||||
|
|||||||
13
src/tests.cpp
Normal file
13
src/tests.cpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#include "config.hpp"
|
||||||
|
#include <catch2/catch_all.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
TEST_CASE("Checking config file read", "[config]") {
|
||||||
|
const std::string FILE_NAME = "../config/config_example.toml";
|
||||||
|
|
||||||
|
Config config = get_config(FILE_NAME);
|
||||||
|
|
||||||
|
REQUIRE(config.contact.author == "author");
|
||||||
|
REQUIRE(config.contact.email == "email@example.com");
|
||||||
|
REQUIRE(config.contact.signal == "signal url");
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user