@@ -98,7 +98,7 @@ void add_2(void)
9898
9999} // end extern "C"
100100
101- TEST_F (CheckMultiExpose, DataWithSameName )
101+ TEST_F (CheckMultiExpose, DataWithSameNameWithDifferentPointer )
102102{
103103 InitPdi (PC_parse_string (R"==(
104104logging: trace
@@ -111,11 +111,56 @@ logging: trace
111111 add_2: { value: $pdi_var1 }
112112)==" ));
113113
114- const int var1 = 3 ;
115- const int var2 = 11 ;
114+ int var1 = 3 ;
115+ int var2 = 11 ;
116116
117117 PDI_multi_expose (" my_test" , " pdi_var1" , &var1, PDI_OUT, " pdi_var1" , &var2, PDI_OUT, NULL );
118118
119119 EXPECT_EQ (var1, 3 ) << " Wrong value of var1" ; // the reference of pdi_var1 in the store is &var2 => no change in the value
120120 EXPECT_EQ (var2, 15 ) << " Wrong value of var2" ; // the add_2 function is called two times on reference &var2.
121121}
122+
123+ TEST_F (CheckMultiExpose, DataWithSameName)
124+ {
125+ InitPdi (PC_parse_string (R"==(
126+ logging: trace
127+ data:
128+ pdi_var1: int
129+ plugins:
130+ user_code:
131+ on_data:
132+ pdi_var1:
133+ add_2: { value: $pdi_var1 }
134+ )==" ));
135+
136+ int var1 = 3 ;
137+ int var2 = 11 ;
138+
139+ PDI_multi_expose (" my_test" , " pdi_var1" , &var1, PDI_OUT, " pdi_var1" , &var1, PDI_OUT, NULL );
140+
141+ EXPECT_EQ (var1, 7 ) << " Wrong value of var1" ; // the reference of pdi_var1 in the store is &var2 => no change in the value
142+ EXPECT_EQ (var2, 11 ) << " Wrong value of var2" ; // the add_2 function is called two times on reference &var2.
143+ }
144+
145+ TEST_F (CheckMultiExpose, WriteFileName)
146+ {
147+ InitPdi (PC_parse_string (R"==(
148+ logging: trace
149+ data:
150+ pdi_var1: int
151+ iter: int
152+ plugins:
153+ decl_hdf5:
154+ file: "myfile_iter${iter}.h5"
155+ write: [pdi_var1]
156+ )==" ));
157+
158+ const int iter = 3 ;
159+ const int var1 = 11 ;
160+
161+ ASSERT_FALSE (std::filesystem::exists (" myfile_iter3.h5" ));
162+
163+ PDI_multi_expose (" my_test" , " pdi_var1" , &var1, PDI_OUT, " iter" , &iter, PDI_INOUT, NULL );
164+
165+ EXPECT_TRUE (std::filesystem::exists (" myfile_iter3.h5" ));
166+ }
0 commit comments