#include <ModelHighAPI_Double.h>
#include <ConstructionAPI_Point.h>
-#include "MockModelAPI_AttributeDouble.h"
-#include "MockModelAPI_Data.h"
-#include "MockModelAPI_Document.h"
-#include "MockModelAPI_Feature.h"
+#include <MockEvents_Listener.h>
+
+#include <MockModelAPI_AttributeDouble.h>
+#include <MockModelAPI_Data.h>
+#include <MockModelAPI_Document.h>
+#include <MockModelAPI_Feature.h>
using ::testing::_;
using ::testing::Return;
// TODO(spo): should be common function
void null_deleter(void *) {}
-class MockEvents_Listener : public Events_Listener {
-public:
- MOCK_METHOD1(processEvent,
- void(const std::shared_ptr<Events_Message>& theMessage));
-};
-
class ConstructionAPI_Point_Constructor_Test : public Test {
public:
MockEvents_Listener aErrorListener;
SET(PROJECT_LIBRARIES
Config
Events
+ ModelAPI
)
ADD_DEFINITIONS(-DMODELHIGHAPI_EXPORTS)
ADD_UNIT_TESTS(
TestDouble.py
)
+
+ADD_SUBDIRECTORY (Test)
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#ifndef MockEvents_Listener_H_
+#define MockEvents_Listener_H_
+
+#include <gmock/gmock.h>
+
+#include <Events_Listener.h>
+
+class MockEvents_Listener : public Events_Listener {
+public:
+ MOCK_METHOD1(processEvent,
+ void(const std::shared_ptr<Events_Message>& theMessage));
+};
+
+#endif // MockEvents_Listener_H_
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
-ModelHighAPI_Double::ModelHighAPI_Double()
-{
-}
-
ModelHighAPI_Double::ModelHighAPI_Double(double theValue)
: myValue(theValue)
{
class ModelHighAPI_Double
{
public:
- /// Default constructor
- ModelHighAPI_Double();
/// Constructor for double
- ModelHighAPI_Double(double theValue);
+ ModelHighAPI_Double(double theValue = 0.);
/// Constructor for std::string
ModelHighAPI_Double(const std::string & theValue);
/// Constructor for char *
--- /dev/null
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+include(GTest)
+
+set(PROJECT_SOURCES
+ TestDouble.cpp
+)
+
+include_directories(
+ ${PROJECT_SOURCE_DIR}/src/ModelHighAPI
+ ${PROJECT_SOURCE_DIR}/src/ModelHighAPI/Mock
+)
+
+set(PROJECT_LIBRARIES
+ ModelHighAPI
+)
+
+set(PACKAGE_NAME "ModelHighAPI")
+set(TARGET_NAME "Test${PACKAGE_NAME}")
+
+add_executable(${TARGET_NAME} ${PROJECT_SOURCES})
+target_link_libraries(${TARGET_NAME} ${PROJECT_LIBRARIES} ${GTEST_LIBRARY})
+
+GTEST_ADD_TESTS(${CMAKE_BINARY_DIR}/bin/${TARGET_NAME} "" ${PROJECT_SOURCES})
--- /dev/null
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include <ModelHighAPI_Double.h>
+
+#include <MockModelAPI_AttributeDouble.h>
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::ReturnRefOfCopy;
+using ::testing::Test;
+
+// TODO(spo): should be common function
+void null_deleter(void *) {}
+
+class HighModelAPI_Double_Test : public Test {
+public:
+ MockModelAPI_AttributeDouble aMockAttributeDouble;
+ std::shared_ptr<ModelAPI_AttributeDouble> anAttributeDouble;
+
+ HighModelAPI_Double_Test() {
+ anAttributeDouble = std::shared_ptr<ModelAPI_AttributeDouble>(&aMockAttributeDouble, &null_deleter);
+ }
+
+ ~HighModelAPI_Double_Test() {
+ }
+};
+
+TEST_F(HighModelAPI_Double_Test, Default) {
+ ModelHighAPI_Double aValue;
+
+ EXPECT_CALL(aMockAttributeDouble, setValue(0.));
+
+ aValue.fillAttribute(anAttributeDouble);
+}
+
+TEST_F(HighModelAPI_Double_Test, Double) {
+ ModelHighAPI_Double aValue(100);
+
+ EXPECT_CALL(aMockAttributeDouble, setValue(100.));
+
+ aValue.fillAttribute(anAttributeDouble);
+}
+
+TEST_F(HighModelAPI_Double_Test, Char) {
+ ModelHighAPI_Double aValue("20");
+
+ EXPECT_CALL(aMockAttributeDouble, setText("20"));
+
+ aValue.fillAttribute(anAttributeDouble);
+}
+
+TEST_F(HighModelAPI_Double_Test, String) {
+ ModelHighAPI_Double aValue(std::string("x + 30"));
+
+ EXPECT_CALL(aMockAttributeDouble, setText("x + 30"));
+
+ aValue.fillAttribute(anAttributeDouble);
+}