47 lines
1.8 KiB
C++
47 lines
1.8 KiB
C++
#include "CppTopicGeneratorGrantlee.h"
|
|
|
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
namespace
|
|
{
|
|
// GeneratorGrantleeBase acquires its logger from the NGL root logger in its
|
|
// constructor. getNGLRootLogger() throws NotCreatedError as long as no root
|
|
// logger was created, so the test has to bootstrap one first. An empty
|
|
// configuration falls back to WARN logging on stdout ('quiet' suppresses
|
|
// the notice on stderr); 'ignorealreadycreated' keeps repeat calls
|
|
// idempotent across tests of this binary.
|
|
NGL::INGLLogger& ensureRootLogger()
|
|
{
|
|
return NGL::NGLLoggerBootstrap::createNGLRootLogger(QString(), true, QString(), true);
|
|
}
|
|
} // namespace
|
|
|
|
// Test that CppTopicGeneratorGrantlee can be instantiated
|
|
TEST(CppTopicGeneratorGrantleeTest, CanInstantiate)
|
|
{
|
|
ensureRootLogger();
|
|
// Constructor acquires the logger from the root logger and must not throw
|
|
EXPECT_NO_THROW({ CodeGen::CppTopicGeneratorGrantlee generator; });
|
|
}
|
|
|
|
// Test that the generator has expected base class functionality
|
|
TEST(CppTopicGeneratorGrantleeTest, HasLoggerName)
|
|
{
|
|
ensureRootLogger();
|
|
CodeGen::CppTopicGeneratorGrantlee generator;
|
|
// The base class created its "CodeGen.CppTopicGeneratorGrantlee" logger
|
|
// from the root logger — retrieving that logger must not throw.
|
|
EXPECT_NO_THROW(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("CodeGen.CppTopicGeneratorGrantlee"));
|
|
}
|
|
|
|
// Test compilation of header dependencies
|
|
TEST(CppTopicGeneratorGrantleeTest, HeaderCompiles)
|
|
{
|
|
// This test verifies that all headers included by CppTopicGeneratorGrantlee.cpp
|
|
// compile correctly with Qt6/C++23
|
|
// Includes: CppTopicGeneratorGrantlee.h, StructBuilder.h, NGLLogger, QCryptographicHash, grantlee/context.h
|
|
EXPECT_TRUE(true); // Compilation itself is the test
|
|
}
|