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

Function TEST

src/alfalfa/test/AlfalfaJSON_GTest.cpp:47–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45using namespace openstudio::model;
46
47TEST(AlfalfaJSON, basic_export) {
48 AlfalfaJSON alfalfa;
49 AlfalfaPoint constant = alfalfa.exposeConstant(17, "hello").get();
50
51 // Check that point has output of type "Constant"
52 ASSERT_TRUE(constant.output().is_initialized());
53 EXPECT_EQ(constant.output().get().typeName(), "Constant");
54 // Check that point does not have an input
55 EXPECT_FALSE(constant.input().is_initialized());
56
57 const AlfalfaPoint meter = alfalfa.exposeMeter("Electricity:Facility").get();
58 std::cout << "here" << std::endl;
59
60 // Check that point has output of type "Meter"
61 ASSERT_TRUE(meter.output().is_initialized());
62 EXPECT_EQ(meter.output().get().typeName(), "Meter");
63 // Check that point does not have an input
64 EXPECT_FALSE(meter.input().is_initialized());
65
66 const AlfalfaPoint actuator = alfalfa.exposeActuator("thing1", "thing2", "thing3").get();
67
68 // Check that point has output of type "Actuator"
69 ASSERT_TRUE(actuator.output().is_initialized());
70 EXPECT_EQ(actuator.output().get().typeName(), "Actuator");
71 // Check that point has input of type "Actuator"
72 ASSERT_TRUE(actuator.input().is_initialized());
73 EXPECT_EQ(actuator.input().get().typeName(), "Actuator");
74
75 const AlfalfaPoint output_variable = alfalfa.exposeOutputVariable("key", "name").get();
76
77 // Check that point has output of type "OutputVariable"
78 ASSERT_TRUE(output_variable.output().is_initialized());
79 EXPECT_EQ(output_variable.output().get().typeName(), "OutputVariable");
80 // Check that point does not have an input
81 EXPECT_FALSE(output_variable.input().is_initialized());
82
83 const AlfalfaPoint global_variable = alfalfa.exposeGlobalVariable("name").get();
84
85 // Check that point has output of type "GlobalVariable"
86 ASSERT_TRUE(global_variable.output().is_initialized());
87 EXPECT_EQ(global_variable.output().get().typeName(), "GlobalVariable");
88 // Check that point has input of type "GlobalVariable"
89 ASSERT_TRUE(global_variable.input().is_initialized());
90 EXPECT_EQ(global_variable.input().get().typeName(), "GlobalVariable");
91
92 std::vector<AlfalfaPoint> points = alfalfa.points();
93
94 ASSERT_EQ(points.size(), 5);
95
96 constant.setUnits("mW");
97
98 EXPECT_EQ("mW", points.at(0).units().get());
99
100 EXPECT_EQ(constant, points.at(0));
101 EXPECT_EQ(meter, points.at(1));
102 EXPECT_EQ(actuator, points.at(2));
103 EXPECT_EQ(output_variable, points.at(3));
104 EXPECT_EQ(global_variable, points.at(4));

Callers

nothing calls this directly

Calls 15

tempDirFunction · 0.85
toSystemFilenameFunction · 0.85
exposeConstantMethod · 0.80
outputMethod · 0.80
typeNameMethod · 0.80
inputMethod · 0.80
exposeMeterMethod · 0.80
exposeActuatorMethod · 0.80
exposeOutputVariableMethod · 0.80
exposeGlobalVariableMethod · 0.80
setLogLevelMethod · 0.80
setInputMethod · 0.80

Tested by

no test coverage detected