MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / TEST_F

Function TEST_F

src/model/test/ResourceObject_GTest.cpp:70–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68*/
69
70TEST_F(ModelFixture, ResourceObject_Clone) {
71 Model original;
72 Construction construction(original);
73 construction.standardsInformation();
74 StandardOpaqueMaterial material(original);
75 bool ok = construction.setLayers(MaterialVector(1u, material));
76 EXPECT_TRUE(ok);
77 EXPECT_EQ(3u, original.numObjects()) << original;
78 EXPECT_EQ(1u, construction.numLayers()) << construction;
79
80 // clone into original
81 auto newConstruction = construction.clone(original).cast<Construction>();
82 // self cloned
83 EXPECT_FALSE(newConstruction == construction);
84 EXPECT_TRUE(newConstruction.model() == construction.model());
85 // child cloned
86 EXPECT_EQ(2u, original.getConcreteModelObjects<StandardsInformationConstruction>().size()) << original;
87 EXPECT_FALSE(newConstruction.standardsInformation() == construction.standardsInformation());
88 EXPECT_EQ(2u, original.getConcreteModelObjects<StandardsInformationConstruction>().size()) << original;
89 // resource not cloned
90 EXPECT_EQ(1u, newConstruction.numLayers());
91 EXPECT_TRUE(newConstruction.layers() == construction.layers());
92 EXPECT_EQ(5u, original.numObjects()) << original;
93
94 // clone into new model
95 Model newModel;
96 newConstruction = construction.clone(newModel).cast<Construction>();
97 EXPECT_FALSE(newConstruction.model() == construction.model());
98 EXPECT_EQ(3u, newModel.numObjects()) << newModel;
99 EXPECT_EQ("Material 1", newConstruction.layers()[0].name().get());
100 // clone again -- object and child added again, resource reused
101 auto anotherNewConstruction = construction.clone(newModel).cast<Construction>();
102 EXPECT_FALSE(anotherNewConstruction == newConstruction);
103 EXPECT_EQ(5u, newModel.numObjects()) << newModel;
104 EXPECT_EQ("Material 1", anotherNewConstruction.layers()[0].name().get());
105 // change resource data
106 newConstruction.layers()[0].setName("Material with Changed Data");
107 // clone again -- all added again
108 anotherNewConstruction = construction.clone(newModel).cast<Construction>();
109 EXPECT_EQ(8u, newModel.numObjects()) << newModel;
110 EXPECT_EQ("Material with Changed Data", newConstruction.layers()[0].name().get());
111 EXPECT_EQ("Material 1", anotherNewConstruction.layers()[0].name().get());
112}

Callers

nothing calls this directly

Calls 11

numLayersMethod · 0.80
layersMethod · 0.80
standardsInformationMethod · 0.45
setLayersMethod · 0.45
numObjectsMethod · 0.45
cloneMethod · 0.45
modelMethod · 0.45
sizeMethod · 0.45
getMethod · 0.45
nameMethod · 0.45
setNameMethod · 0.45

Tested by

no test coverage detected