]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelHighAPI/Test/TestDouble.cpp
Salome HOME
Fix tests MakeBrick2 & MakeBrick3. Fix Box macro feature.
[modules/shaper.git] / src / ModelHighAPI / Test / TestDouble.cpp
1 #include <gtest/gtest.h>
2 #include <gmock/gmock.h>
3
4 #include <ModelHighAPI_Double.h>
5
6 #include <MockModelAPI_AttributeDouble.h>
7
8 using ::testing::_;
9 using ::testing::Return;
10 using ::testing::ReturnRefOfCopy;
11 using ::testing::Test;
12
13 // TODO(spo): should be common function
14 static void null_deleter(void *) {}
15
16 class HighModelAPI_Double_Test : public Test {
17 public:
18   MockModelAPI_AttributeDouble aMockAttributeDouble;
19   std::shared_ptr<ModelAPI_AttributeDouble> anAttributeDouble;
20
21   HighModelAPI_Double_Test() {
22     anAttributeDouble = std::shared_ptr<ModelAPI_AttributeDouble>(&aMockAttributeDouble, &null_deleter);
23   }
24
25   ~HighModelAPI_Double_Test() {
26   }
27 };
28
29 TEST_F(HighModelAPI_Double_Test, Default) {
30   ModelHighAPI_Double aValue;
31
32   EXPECT_CALL(aMockAttributeDouble, setValue(0.));
33
34   aValue.fillAttribute(anAttributeDouble);
35 }
36
37 TEST_F(HighModelAPI_Double_Test, Double) {
38   ModelHighAPI_Double aValue(100.5);
39
40   EXPECT_CALL(aMockAttributeDouble, setValue(100.5));
41
42   aValue.fillAttribute(anAttributeDouble);
43 }
44
45 TEST_F(HighModelAPI_Double_Test, Char) {
46   ModelHighAPI_Double aValue("20");
47
48   EXPECT_CALL(aMockAttributeDouble, setText("20"));
49
50   aValue.fillAttribute(anAttributeDouble);
51 }
52
53 TEST_F(HighModelAPI_Double_Test, String) {
54   ModelHighAPI_Double aValue(std::string("x + 30"));
55
56   EXPECT_CALL(aMockAttributeDouble, setText("x + 30"));
57
58   aValue.fillAttribute(anAttributeDouble);
59 }