Fix: Remove circular dependencies in headers (#295)

* Remove circular dependencies in headers

* Fix unit test includes and test data directory location
This commit is contained in:
Vladislav Navrocky
2025-02-11 11:03:42 +03:00
committed by GitHub
parent 17ba53cb9e
commit 384a6bef3f
17 changed files with 97 additions and 69 deletions
+9
View File
@@ -0,0 +1,9 @@
#ifndef INCLUDE_TEST_COMMON_HPP_
#define INCLUDE_TEST_COMMON_HPP_
#include <string>
#include <doctest/doctest.h>
extern const std::string test_file_directory;
#endif // INCLUDE_TEST_COMMON_HPP_
+4 -4
View File
@@ -1,9 +1,8 @@
// Copyright (c) 2020 Pantor. All rights reserved.
#include <doctest/doctest.h>
#include "inja/environment.hpp"
#include "inja/inja.hpp"
#include "test-common.hpp"
TEST_CASE("loading") {
inja::Environment env;
@@ -99,7 +98,8 @@ TEST_CASE("include-in-memory-and-file-template") {
inja::json data;
data["name"] = "Jeff";
CHECK_THROWS_WITH(env.render_file("include-both.txt", data), "[inja.exception.file_error] failed accessing file at '../test/data/body'");
std::string error_message = "[inja.exception.file_error] failed accessing file at '" + test_file_directory + "body'";
CHECK_THROWS_WITH(env.render_file("include-both.txt", data), error_message.c_str());
const auto parsed_body_template = env.parse("Bye {{ name }}.");
env.include_template("body", parsed_body_template);
+2 -4
View File
@@ -1,10 +1,8 @@
// Copyright (c) 2020 Pantor. All rights reserved.
#include <doctest/doctest.h>
#include <string>
#include "inja/environment.hpp"
#include "inja/inja.hpp"
#include "test-common.hpp"
TEST_CASE("functions") {
inja::Environment env;
+2 -5
View File
@@ -1,11 +1,8 @@
// Copyright (c) 2020 Pantor. All rights reserved.
#include <doctest/doctest.h>
#include <string>
#include "inja/environment.hpp"
#include "inja/inja.hpp"
#include "inja/template.hpp"
#include "test-common.hpp"
TEST_CASE("types") {
inja::Environment env;
+2 -6
View File
@@ -1,12 +1,8 @@
// Copyright (c) 2020 Pantor. All rights reserved.
#include <doctest/doctest.h>
#include <string>
#include "inja/environment.hpp"
#include "inja/function_storage.hpp"
#include "inja/inja.hpp"
#include "inja/utils.hpp"
#include "test-common.hpp"
TEST_CASE("source location") {
std::string content = R""""(Lorem Ipsum
+5 -6
View File
@@ -1,16 +1,15 @@
// Copyright (c) 2020 Pantor. All rights reserved.
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <doctest/doctest.h>
#define JSON_USE_IMPLICIT_CONVERSIONS 0
#define JSON_NO_IO 1
#include "inja/inja.hpp"
const std::string test_file_directory {"../test/data/"};
#include "test-files.cpp"
#include "test-functions.cpp"
#include "test-renderer.cpp"
#include "test-units.cpp"
#define xstr(s) str(s)
#define str(s) #s
const std::string test_file_directory { xstr(__TEST_DIR__)"/data/" };