1 /** 2 * 3 * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(_at_LIP6) & Christophe GONZALES(_at_AMU) 4 * info_at_agrum_dot_org 5 * 6 * This library is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU Lesser General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public License 17 * along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 */ 20 21 22 #include <iostream> 23 #include <string> 24 25 #include <agrum/tools/core/math/math_utils.h> 26 #include <agrum/BN/BayesNet.h> 27 #include <agrum/BN/io/DSL/DSLReader.h> 28 #include <agrum/BN/io/DSL/DSLWriter.h> 29 #include <agrum/tools/variables/labelizedVariable.h> 30 #include <gumtest/AgrumTestSuite.h> 31 #include <gumtest/testsuite_utils.h> 32 // The graph used for the tests: 33 // 1 2_ 1 -> 3 34 // / \ / / 1 -> 4 35 // 3 4 / 3 -> 5 36 // \ / / 4 -> 5 37 // 5_/ 2 -> 4 38 // 2 -> 5 39 namespace gum_tests { 40 class DSLReaderTestSuite: public CxxTest::TestSuite { 41 public: testConstuctor()42 void testConstuctor() { 43 std::string file = GET_RESSOURCES_PATH("DSL/DSLReader_file1.txt"); 44 gum::BayesNet< double > net; 45 46 gum::DSLReader< double >* reader = 0; 47 TS_GUM_ASSERT_THROWS_NOTHING(reader = new gum::DSLReader< double >(&net, file)); 48 TS_GUM_ASSERT_THROWS_NOTHING(delete reader); 49 } testRead_file1()50 void testRead_file1() { 51 std::string file = GET_RESSOURCES_PATH("DSL/DSLReader_file1.txt"); 52 gum::BayesNet< double >* net = new gum::BayesNet< double >(); 53 gum::DSLReader< double > reader(net, file); 54 55 reader.trace(false); 56 57 gum::Size nbrErr = (gum::Size)0; 58 TS_GUM_ASSERT_THROWS_NOTHING(nbrErr = reader.proceed()); 59 TS_ASSERT_EQUALS(nbrErr, (gum::Size)0) 60 TS_ASSERT_EQUALS(reader.warnings(), (gum::Size)0) 61 // 0 warnings : no properties 62 TS_ASSERT_EQUALS(reader.errors(), (gum::Size)0) 63 TS_ASSERT_DIFFERS(net, nullptr) 64 65 if (net != nullptr) { 66 TS_ASSERT(net->empty()) 67 delete net; 68 } 69 } testRead_file2_float()70 void testRead_file2_float() { 71 std::string file = GET_RESSOURCES_PATH("DSL/DSLReader_file2.txt"); 72 gum::BayesNet< double >* net = new gum::BayesNet< double >(); 73 gum::DSLReader< double > reader(net, file); 74 gum::Size nbrErr = (gum::Size)0; 75 TS_GUM_ASSERT_THROWS_NOTHING(nbrErr = reader.proceed()); 76 TS_ASSERT_EQUALS(nbrErr, (gum::Size)0) 77 TS_ASSERT_EQUALS(reader.warnings(), (gum::Size)0) 78 // 0 warnings : no properties 79 TS_ASSERT_EQUALS(reader.errors(), (gum::Size)0) 80 81 TS_ASSERT_DIFFERS(net, nullptr) 82 83 if (net != nullptr) { 84 TS_ASSERT_EQUALS(net->size(), (gum::Size)2) 85 gum::NodeId node_1 = 0, node_2 = 0; 86 87 for (const auto node: net->nodes()) 88 if (net->variable(node).name() == "n1") 89 node_1 = node; 90 else 91 node_2 = node; 92 93 const gum::DiscreteVariable& var_1 = net->variable(node_1); 94 95 TS_ASSERT_EQUALS(var_1.name(), "n1") 96 TS_ASSERT_EQUALS(var_1.domainSize(), (gum::Size)2) 97 const gum::Potential< double >& proba_1 = net->cpt(node_1); 98 TS_ASSERT_EQUALS(proba_1.domainSize(), (gum::Size)2) 99 gum::Instantiation inst_1(proba_1); 100 inst_1.setFirst(); 101 TS_ASSERT(std::abs((proba_1[inst_1] - 0.2f)) < 0.001f) 102 inst_1.setLast(); 103 TS_ASSERT(std::abs((proba_1[inst_1] - 0.8f)) < 0.001f) 104 105 const gum::DiscreteVariable& var_2 = net->variable(node_2); 106 TS_ASSERT_EQUALS(var_2.name(), "n2") 107 TS_ASSERT_EQUALS(var_2.domainSize(), (gum::Size)2) 108 const gum::Potential< double >& proba_2 = net->cpt(node_2); 109 TS_ASSERT_EQUALS(proba_2.domainSize(), (gum::Size)2) 110 gum::Instantiation inst_2(proba_2); 111 inst_2.setFirst(); 112 TS_ASSERT(std::abs((proba_2[inst_2] - 0.3f)) < 0.001f) 113 inst_2.setLast(); 114 TS_ASSERT(std::abs((proba_2[inst_2] - 0.7f)) < 0.001f) 115 116 delete net; 117 } 118 } testRead_file2_double()119 void testRead_file2_double() { 120 std::string file = GET_RESSOURCES_PATH("DSL/DSLReader_file2.txt"); 121 gum::BayesNet< double >* net = new gum::BayesNet< double >(); 122 gum::DSLReader< double > reader(net, file); 123 124 gum::Size nbrErr = (gum::Size)0; 125 TS_GUM_ASSERT_THROWS_NOTHING(nbrErr = reader.proceed()); 126 TS_ASSERT_EQUALS(nbrErr, (gum::Size)0) 127 TS_ASSERT_EQUALS(reader.warnings(), (gum::Size)0) 128 TS_ASSERT_EQUALS(reader.errors(), (gum::Size)0) 129 130 TS_ASSERT_DIFFERS(net, nullptr) 131 132 if (net != nullptr) { 133 TS_ASSERT_EQUALS(net->size(), (gum::Size)2) 134 gum::NodeId node_1 = 0, node_2 = 0; 135 136 for (const auto node: net->nodes()) 137 if (net->variable(node).name() == "n1") 138 node_1 = node; 139 else 140 node_2 = node; 141 142 const gum::DiscreteVariable& var_1 = net->variable(node_1); 143 144 TS_ASSERT_EQUALS(var_1.name(), "n1") 145 TS_ASSERT_EQUALS(var_1.domainSize(), (gum::Size)2) 146 const gum::Potential< double >& proba_1 = net->cpt(node_1); 147 TS_ASSERT_EQUALS(proba_1.domainSize(), (gum::Size)2) 148 gum::Instantiation inst_1(proba_1); 149 inst_1.setFirst(); 150 TS_ASSERT(std::abs((proba_1[inst_1] - 0.2)) < 0.001) 151 inst_1.setLast(); 152 TS_ASSERT(std::abs((proba_1[inst_1] - 0.8)) < 0.001) 153 154 const gum::DiscreteVariable& var_2 = net->variable(node_2); 155 TS_ASSERT_EQUALS(var_2.name(), "n2") 156 TS_ASSERT_EQUALS(var_2.domainSize(), (gum::Size)2) 157 const gum::Potential< double >& proba_2 = net->cpt(node_2); 158 TS_ASSERT_EQUALS(proba_2.domainSize(), (gum::Size)2) 159 gum::Instantiation inst_2(proba_2); 160 inst_2.setFirst(); 161 TS_ASSERT(std::abs((proba_2[inst_2] - 0.3)) < 0.001) 162 inst_2.setLast(); 163 TS_ASSERT(std::abs((proba_2[inst_2] - 0.7)) < 0.001) 164 165 delete net; 166 } 167 } testRead_file3()168 void testRead_file3() { 169 std::string file = GET_RESSOURCES_PATH("DSL/DSLReader_file3.txt"); 170 gum::BayesNet< double >* net = new gum::BayesNet< double >(); 171 gum::DSLReader< double > reader(net, file); 172 gum::Size nbrErr = (gum::Size)0; 173 TS_GUM_ASSERT_THROWS_NOTHING(nbrErr = reader.proceed()); 174 TS_ASSERT_EQUALS(nbrErr, (gum::Size)0) 175 TS_ASSERT_EQUALS(reader.warnings(), (gum::Size)0) 176 // 0 warnings : no properties 177 TS_ASSERT_EQUALS(reader.errors(), (gum::Size)0) 178 TS_ASSERT_EQUALS(net->size(), (gum::Size)6) 179 TS_ASSERT_DIFFERS(net, nullptr) 180 gum::DSLWriter< double > writer; 181 std::string file2 = GET_RESSOURCES_PATH("outputs/DSLWriter_TestFile3.txt"); 182 TS_GUM_ASSERT_THROWS_NOTHING(writer.write(file2, *net)); 183 184 if (net) delete net; 185 } testRead_file_completeDSL()186 void testRead_file_completeDSL() { 187 std::string file = GET_RESSOURCES_PATH("DSL/Ling.dsl"); 188 gum::BayesNet< double >* net = new gum::BayesNet< double >(); 189 gum::DSLReader< double > reader(net, file); 190 gum::Size nbrErr = (gum::Size)0; 191 reader.trace(true); 192 TS_GUM_ASSERT_THROWS_NOTHING(nbrErr = reader.proceed()); 193 TS_ASSERT_EQUALS(nbrErr, (gum::Size)0) 194 TS_ASSERT_EQUALS(reader.warnings(), (gum::Size)0) 195 // 0 warnings : no properties 196 TS_ASSERT_EQUALS(reader.errors(), (gum::Size)0) 197 TS_ASSERT_EQUALS(net->size(), (gum::Size)13) 198 TS_ASSERT_DIFFERS(net, nullptr) 199 gum::DSLWriter< double > writer; 200 std::string file2 = GET_RESSOURCES_PATH("outputs/DSLWriter_Ling.txt"); 201 TS_GUM_ASSERT_THROWS_NOTHING(writer.write(file2, *net)); 202 203 if (net) delete net; 204 } testAlarm()205 void testAlarm() { 206 std::string file = GET_RESSOURCES_PATH("DSL/alarm.dsl"); 207 gum::BayesNet< double >* net = new gum::BayesNet< double >(); 208 gum::DSLReader< double > reader(net, file); 209 210 gum::Size nbrErr = (gum::Size)0; 211 TS_GUM_ASSERT_THROWS_NOTHING(nbrErr = reader.proceed()); 212 TS_ASSERT_EQUALS(nbrErr, (gum::Size)0) 213 TS_ASSERT_EQUALS(reader.warnings(), (gum::Size)0) 214 TS_ASSERT_EQUALS(reader.errors(), (gum::Size)0) 215 216 gum::HashTable< std::string, gum::NodeId > idMap; 217 218 for (const auto node: net->nodes()) 219 idMap.insert(net->variable(node).name(), node); 220 221 // The node wich we'll test 222 TS_ASSERT(idMap.exists("HISTORY")) 223 // It's parent 224 TS_ASSERT(idMap.exists("LVFAILURE")) 225 226 if (idMap.exists("HISTORY") && idMap.exists("LVFAILURE")) { 227 const gum::DiscreteVariable& history = net->variable(idMap["HISTORY"]); 228 TS_ASSERT_EQUALS(history.domainSize(), (gum::Size)2) 229 TS_ASSERT_EQUALS(history.label(0), "TRUE") 230 TS_ASSERT_EQUALS(history.label(1), "FALSE") 231 TS_ASSERT(net->dag().existsArc(idMap["LVFAILURE"], idMap["HISTORY"])) 232 const gum::Potential< double >& historyCPT = net->cpt(idMap["HISTORY"]); 233 TS_ASSERT_EQUALS(historyCPT.domainSize(), (gum::Size)4) 234 TS_ASSERT(historyCPT.contains(net->variable(idMap["HISTORY"]))) 235 TS_ASSERT(historyCPT.contains(net->variable(idMap["LVFAILURE"]))) 236 gum::Instantiation historyInst(historyCPT); 237 // (TRUE | TRUE) 238 historyInst.chgVal(history, 0); 239 historyInst.chgVal(net->variable(idMap["LVFAILURE"]), 0); 240 TS_ASSERT(std::abs(historyCPT[historyInst] - 0.9f) < 0.0001f) 241 // (FALSE | TRUE) 242 historyInst.chgVal(history, 1); 243 historyInst.chgVal(net->variable(idMap["LVFAILURE"]), 0); 244 TS_ASSERT(std::abs(historyCPT[historyInst] - 0.1f) < 0.0001f) 245 // (TRUE | FALSE) 246 historyInst.chgVal(history, 0); 247 historyInst.chgVal(net->variable(idMap["LVFAILURE"]), 1); 248 TS_ASSERT(std::abs(historyCPT[historyInst] - 0.01f) < 0.0001f) 249 // (FALSE | FALSE) 250 historyInst.chgVal(history, 1); 251 historyInst.chgVal(net->variable(idMap["LVFAILURE"]), 1); 252 TS_ASSERT(std::abs(historyCPT[historyInst] - 0.99f) < 0.0001f) 253 } 254 255 // The node wich we'll test 256 TS_ASSERT(idMap.exists("ERRLOWOUTPUT")) 257 // It's Children 258 TS_ASSERT(idMap.exists("HRBP")) 259 260 if (idMap.exists("ERRLOWOUTPUT") && idMap.exists("HRBP")) { 261 const gum::DiscreteVariable& errlowoutput = net->variable(idMap["ERRLOWOUTPUT"]); 262 TS_ASSERT_EQUALS(errlowoutput.domainSize(), (gum::Size)2) 263 TS_ASSERT_EQUALS(errlowoutput.label(0), "TRUE") 264 TS_ASSERT_EQUALS(errlowoutput.label(1), "FALSE") 265 TS_ASSERT(net->dag().existsArc(idMap["ERRLOWOUTPUT"], idMap["HRBP"])) 266 const gum::Potential< double >& errlowoutputCPT = net->cpt(idMap["ERRLOWOUTPUT"]); 267 TS_ASSERT_EQUALS(errlowoutputCPT.domainSize(), (gum::Size)2) 268 TS_ASSERT(errlowoutputCPT.contains(errlowoutput)) 269 gum::Instantiation errlowoutputInst(errlowoutputCPT); 270 errlowoutputInst.chgVal(errlowoutput, 0); 271 TS_ASSERT(std::abs(errlowoutputCPT[errlowoutputInst] - 0.05f) < 0.001f) 272 errlowoutputInst.chgVal(errlowoutput, 1); 273 TS_ASSERT(std::abs(errlowoutputCPT[errlowoutputInst] - 0.95f) < 0.001f) 274 } 275 276 // The nide wich we'll test 277 TS_ASSERT(idMap.exists("LVEDVOLUME")) 278 // It's parents 279 TS_ASSERT(idMap.exists("HYPOVOLEMIA")) 280 TS_ASSERT(idMap.exists("LVFAILURE")) 281 282 if (idMap.exists("LVEDVOLUME") && idMap.exists("HYPOVOLEMIA") && idMap.exists("LVFAILURE")) { 283 const gum::DiscreteVariable& lvedvolume = net->variable(idMap["LVEDVOLUME"]); 284 const gum::DiscreteVariable& hypovolemia = net->variable(idMap["HYPOVOLEMIA"]); 285 const gum::DiscreteVariable& lvfailure = net->variable(idMap["LVFAILURE"]); 286 // checking label order 287 TS_ASSERT_EQUALS(lvedvolume.label(0), "LOW") 288 TS_ASSERT_EQUALS(lvedvolume.label(1), "NORMAL") 289 TS_ASSERT_EQUALS(lvedvolume.label(2), "HIGH") 290 TS_ASSERT_EQUALS(hypovolemia.label(0), "TRUE") 291 TS_ASSERT_EQUALS(hypovolemia.label(1), "FALSE") 292 TS_ASSERT_EQUALS(lvfailure.label(0), "TRUE") 293 TS_ASSERT_EQUALS(lvfailure.label(1), "FALSE") 294 const gum::Potential< double >& cpt = net->cpt(idMap["LVEDVOLUME"]); 295 gum::Instantiation inst(cpt); 296 gum::Instantiation var_inst; 297 var_inst << lvedvolume; 298 inst.chgVal(hypovolemia, 0); 299 inst.chgVal(lvfailure, 0); 300 float array_1[] = {0.95f, 0.04f, 0.01f}; 301 size_t i = 0; 302 303 for (inst.setFirstIn(var_inst); !inst.end(); inst.incIn(var_inst), ++i) { 304 TS_ASSERT_DELTA(cpt[inst], array_1[i], 0.001f) 305 } 306 307 inst.chgVal(hypovolemia, 1); 308 inst.chgVal(lvfailure, 0); 309 float array_2[] = {0.98f, 0.01f, 0.01f}; 310 i = 0; 311 312 for (inst.setFirstIn(var_inst); !inst.end(); inst.incIn(var_inst), ++i) { 313 TS_ASSERT_DELTA(cpt[inst], array_2[i], 0.001f) 314 } 315 316 inst.chgVal(hypovolemia, 0); 317 inst.chgVal(lvfailure, 1); 318 float array_3[] = {0.01f, 0.09f, 0.9f}; 319 i = 0; 320 321 for (inst.setFirstIn(var_inst); !inst.end(); inst.incIn(var_inst), ++i) { 322 TS_ASSERT_DELTA(cpt[inst], array_3[i], 0.001f) 323 } 324 325 inst.chgVal(hypovolemia, 1); 326 inst.chgVal(lvfailure, 1); 327 float array_4[] = {0.05f, 0.9f, 0.05f}; 328 i = 0; 329 330 for (inst.setFirstIn(var_inst); !inst.end(); inst.incIn(var_inst), ++i) { 331 TS_ASSERT_DELTA(cpt[inst], array_4[i], 0.001f) 332 } 333 } 334 335 delete net; 336 } testUnexisting()337 void testUnexisting() { 338 std::string file = "Schmurtz"; 339 gum::BayesNet< double >* net = new gum::BayesNet< double >(); 340 TS_GUM_ASSERT_THROWS_NOTHING(gum::DSLReader< double > reader(net, file)); 341 gum::DSLReader< double > reader(net, file); 342 TS_ASSERT_THROWS(reader.proceed(), gum::IOError) 343 344 if (net) delete net; 345 } testBarley()346 void testBarley() { 347 std::string file = GET_RESSOURCES_PATH("DSL/Barley.dsl"); 348 gum::BayesNet< double >* net = new gum::BayesNet< double >(); 349 gum::DSLReader< double > reader(net, file); 350 gum::Size nbrErr = (gum::Size)0; 351 TS_GUM_ASSERT_THROWS_NOTHING(nbrErr = reader.proceed()); 352 TS_ASSERT_EQUALS(nbrErr, (gum::Size)0) 353 TS_ASSERT_EQUALS(reader.warnings(), (gum::Size)0) 354 TS_ASSERT_EQUALS(reader.errors(), (gum::Size)0) 355 356 if (net) delete net; 357 } testCarpo()358 void testCarpo() { 359 std::string file = GET_RESSOURCES_PATH("DSL/carpo.dsl"); 360 gum::BayesNet< double >* net = new gum::BayesNet< double >(); 361 gum::DSLReader< double > reader(net, file); 362 gum::Size nbrErr = (gum::Size)0; 363 TS_GUM_ASSERT_THROWS_NOTHING(nbrErr = reader.proceed()); 364 TS_ASSERT_EQUALS(nbrErr, (gum::Size)0) 365 TS_ASSERT_EQUALS(reader.warnings(), (gum::Size)0) 366 TS_ASSERT_EQUALS(reader.errors(), (gum::Size)0) 367 368 if (net) delete net; 369 } testDiabetes()370 void testDiabetes() { 371 std::string file = GET_RESSOURCES_PATH("DSL/Diabetes.dsl"); 372 gum::BayesNet< double >* net = new gum::BayesNet< double >(); 373 gum::DSLReader< double > reader(net, file); 374 gum::Size nbrErr = (gum::Size)0; 375 TS_GUM_ASSERT_THROWS_NOTHING(nbrErr = reader.proceed()); 376 TS_ASSERT_EQUALS(nbrErr, (gum::Size)0) 377 TS_ASSERT_EQUALS(reader.warnings(), (gum::Size)0) 378 TS_ASSERT_EQUALS(reader.errors(), (gum::Size)0) 379 380 if (net) delete net; 381 } testHailfinder()382 void testHailfinder() { 383 std::string file = GET_RESSOURCES_PATH("DSL/hailfinder.dsl"); 384 gum::BayesNet< double >* net = new gum::BayesNet< double >(); 385 gum::DSLReader< double > reader(net, file); 386 gum::Size nbrErr = (gum::Size)0; 387 TS_GUM_ASSERT_THROWS_NOTHING(nbrErr = reader.proceed()); 388 TS_ASSERT_EQUALS(nbrErr, (gum::Size)0) 389 TS_ASSERT_EQUALS(reader.warnings(), (gum::Size)0) 390 TS_ASSERT_EQUALS(reader.errors(), (gum::Size)0) 391 392 if (net) delete net; 393 } testInsurance()394 void testInsurance() { 395 std::string file = GET_RESSOURCES_PATH("DSL/insurance.dsl"); 396 gum::BayesNet< double >* net = new gum::BayesNet< double >(); 397 gum::DSLReader< double > reader(net, file); 398 gum::Size nbrErr = (gum::Size)0; 399 TS_GUM_ASSERT_THROWS_NOTHING(nbrErr = reader.proceed()); 400 TS_ASSERT_EQUALS(nbrErr, (gum::Size)0) 401 TS_ASSERT_EQUALS(reader.warnings(), (gum::Size)0) 402 TS_ASSERT_EQUALS(reader.errors(), (gum::Size)0) 403 404 if (net) delete net; 405 } testLink()406 void testLink() { 407 std::string file = GET_RESSOURCES_PATH("DSL/Link.dsl"); 408 gum::BayesNet< double >* net = new gum::BayesNet< double >(); 409 gum::DSLReader< double > reader(net, file); 410 gum::Size nbrErr = (gum::Size)0; 411 TS_GUM_ASSERT_THROWS_NOTHING(nbrErr = reader.proceed()); 412 TS_ASSERT_EQUALS(nbrErr, (gum::Size)0) 413 TS_ASSERT_EQUALS(reader.warnings(), (gum::Size)0) 414 TS_ASSERT_EQUALS(reader.errors(), (gum::Size)0) 415 416 if (net) delete net; 417 } 418 // Mildew is not readable (because of the VERY LARGE FLOAT_LIST in foto_4 419 // (at 420 // least))... Mildew()421 void Mildew() { 422 std::string file = GET_RESSOURCES_PATH("DSL/Mildew.dsl"); 423 gum::BayesNet< double >* net = new gum::BayesNet< double >(); 424 gum::DSLReader< double > reader(net, file); 425 gum::Size nbrErr = (gum::Size)0; 426 TS_GUM_ASSERT_THROWS_NOTHING(nbrErr = reader.proceed()); 427 TS_ASSERT_EQUALS(nbrErr, (gum::Size)0) 428 TS_ASSERT_EQUALS(reader.warnings(), (gum::Size)0) 429 TS_ASSERT_EQUALS(reader.errors(), (gum::Size)0) 430 431 if (net) delete net; 432 } testMunin1()433 void testMunin1() { 434 std::string file = GET_RESSOURCES_PATH("DSL/Munin1.dsl"); 435 gum::BayesNet< double >* net = new gum::BayesNet< double >(); 436 gum::DSLReader< double > reader(net, file); 437 gum::Size nbrErr = (gum::Size)0; 438 TS_GUM_ASSERT_THROWS_NOTHING(nbrErr = reader.proceed()); 439 TS_ASSERT_EQUALS(nbrErr, (gum::Size)0) 440 TS_ASSERT_EQUALS(reader.warnings(), (gum::Size)0) 441 TS_ASSERT_EQUALS(reader.errors(), (gum::Size)0) 442 443 if (net) delete net; 444 } testPigs()445 void testPigs() { 446 std::string file = GET_RESSOURCES_PATH("DSL/Pigs.dsl"); 447 gum::BayesNet< double >* net = new gum::BayesNet< double >(); 448 gum::DSLReader< double > reader(net, file); 449 gum::Size nbrErr = (gum::Size)0; 450 TS_GUM_ASSERT_THROWS_NOTHING(nbrErr = reader.proceed()); 451 TS_ASSERT_EQUALS(nbrErr, (gum::Size)0) 452 TS_ASSERT_EQUALS(reader.warnings(), (gum::Size)0) 453 TS_ASSERT_EQUALS(reader.errors(), (gum::Size)0) 454 455 if (net) delete net; 456 } testWater()457 void testWater() { 458 std::string file = GET_RESSOURCES_PATH("DSL/Water.dsl"); 459 gum::BayesNet< double >* net = new gum::BayesNet< double >(); 460 gum::DSLReader< double > reader(net, file); 461 gum::Size nbrErr = (gum::Size)0; 462 TS_GUM_ASSERT_THROWS_NOTHING(nbrErr = reader.proceed()); 463 TS_ASSERT_EQUALS(nbrErr, (gum::Size)0) 464 TS_ASSERT_EQUALS(reader.warnings(), (gum::Size)0) 465 TS_ASSERT_EQUALS(reader.errors(), (gum::Size)0) 466 467 if (net) delete net; 468 } 469 }; 470 } // namespace gum_tests 471