MCPcopy Create free account
hub / github.com/GENIVI/CANdevStudio / genTestsModel

Function genTestsModel

tools/templategen/main.cpp:881–973  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

879}
880
881std::string genTestsModel(const std::string& name)
882{
883 using namespace fmt::literals;
884
885 return fmt::format(R"(#include <QtWidgets/QApplication>
886#include <{nameLower}model.h>
887#define CATCH_CONFIG_RUNNER
888#include "log.h"
889#include <QCanBusFrame>
890#include <QSignalSpy>
891#include <catch.hpp>
892#include <fakeit.hpp>
893
894std::shared_ptr<spdlog::logger> kDefaultLogger;
895// needed for QSignalSpy cause according to qtbug 49623 comments
896// automatic detection of types is "flawed" in moc
897Q_DECLARE_METATYPE(QCanBusFrame);
898
899TEST_CASE("Test basic functionality", "[{nameLower}Model]")
900{{
901 using namespace fakeit;
902 {name}Model cm;
903 REQUIRE(cm.caption() == "{name}");
904 REQUIRE(cm.name() == "{name}");
905 REQUIRE(cm.resizable() == false);
906 REQUIRE(cm.hasSeparateThread() == false);
907 REQUIRE(dynamic_cast<{name}Model*>(cm.clone().get()) != nullptr);
908 REQUIRE(dynamic_cast<QLabel*>(cm.embeddedWidget()) != nullptr);
909}}
910
911TEST_CASE("painterDelegate", "[{nameLower}Model]")
912{{
913 {name}Model cm;
914 REQUIRE(cm.painterDelegate() != nullptr);
915}}
916
917TEST_CASE("nPorts", "[{nameLower}Model]")
918{{
919 {name}Model cm;
920
921 REQUIRE(cm.nPorts(QtNodes::PortType::Out) == 0);
922 REQUIRE(cm.nPorts(QtNodes::PortType::In) == 0);
923}}
924
925TEST_CASE("dataType", "[{nameLower}Model]")
926{{
927 {name}Model cm;
928
929 NodeDataType ndt;
930
931 // ndt = cm.dataType(QtNodes::PortType::Out, 0);
932 // REQUIRE(ndt.id == "rawframe");
933 // REQUIRE(ndt.name == "RAW");
934
935 // ndt = cm.dataType(QtNodes::PortType::Out, 1);
936 // REQUIRE(ndt.id == "");
937 // REQUIRE(ndt.name == "");
938

Callers 1

mainFunction · 0.85

Calls 2

str_toupperFunction · 0.85
str_tolowerFunction · 0.85

Tested by

no test coverage detected