From 440c84501e7b4565c9f4f66e419f1695594b9936 Mon Sep 17 00:00:00 2001
From: Martin Hierholzer <martin.hierholzer@desy.de>
Date: Tue, 4 Feb 2020 17:22:37 +0100
Subject: [PATCH] enforce to set default values correctly when using
 TestFacility

---
 include/TestFacility.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/TestFacility.h b/include/TestFacility.h
index ac336e60..6d2be730 100644
--- a/include/TestFacility.h
+++ b/include/TestFacility.h
@@ -42,6 +42,11 @@ namespace ChimeraTK {
       for(auto& pv : pvManager->getAllProcessVariables()) {
         callForType(pv->getValueType(), [&pv, this](auto arg) {
           if(!pv->isWriteable()) return;
+          if(pv->getVersionNumber() != VersionNumber(nullptr)) {
+            throw ChimeraTK::logic_error("The variable '" + pv->getName() +
+                "' has been written before TestFacility::runApplication() was called. Instead use "
+                "TestFacility::setScalarDefault() resp. setArrayDefault() to set initial values.");
+          }
           typedef decltype(arg) T;
           auto pv_casted = boost::dynamic_pointer_cast<NDRegisterAccessor<T>>(pv);
           auto table = boost::fusion::at_key<T>(defaults.table);
-- 
GitLab