Skip to content
Snippets Groups Projects
Commit acf283d1 authored by Danilo Piparo's avatar Danilo Piparo
Browse files

[DictGen] Add dictgen unit tests directory and add test for ROOT-8566

parent fa60f437
Branches
Tags
No related merge requests found
......@@ -51,3 +51,5 @@ generateHeader(Dictgen
${CMAKE_SOURCE_DIR}/core/dictgen/src/rootcling-argparse.py
${CMAKE_BINARY_DIR}/include/rootclingCommandLineOptionsHelp.h
)
ROOT_ADD_TEST_SUBDIRECTORY(test)
# @author Danilo Piparo CERN
ROOT_ADD_GTEST(dictgen_base dictgen_base.cxx LIBRARIES Core)
\ No newline at end of file
#include <TSystem.h>
#include <TInterpreter.h>
#include "gtest/gtest.h"
#include <fstream>
TEST(DictGen, ExtraIncludes)
{
auto macroName = "myextramacro.C";
auto macroCode = R"MACROCODE(
#ifdef __ROOTCLING__
#pragma extra_include "myextra.h";
#endif
#include <iostream>
void a(){}
)MACROCODE";
std::ofstream macroFile (macroName);
macroFile << macroCode;
macroFile.close();
auto includeName = "myextra.h";
auto extraInclude = R"EXTRAINCLUDE(
#ifndef __EXTRA_HEADER_H
#define __EXTRA_HEADER_H
int f(){return 42;};
#endif
)EXTRAINCLUDE";
std::ofstream eiFile (includeName);
eiFile << extraInclude;
eiFile.close();
// Here we perform these steps:
// Compile macro which has a linkdef section with extra includes
// The extra includes get parsed. They contain a function, f
// The value returned by f is checked to be correct
gInterpreter->ProcessLine(".L myextramacro.C+");
auto r = gInterpreter->ProcessLine("f()");
EXPECT_EQ(r, 42U);
gSystem->Unlink(macroName);
gSystem->Unlink(includeName);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment