Explorar el Código

Fix start function of DTSS

Eric Ramat hace 5 años
padre
commit
f46a3a0974
Se han modificado 2 ficheros con 43 adiciones y 47 borrados
  1. 14 25
      src/tests/mixed/models.hpp
  2. 29 22
      src/tests/mixed/tests.cpp

+ 14 - 25
src/tests/mixed/models.hpp

@@ -76,7 +76,7 @@ namespace artis {
                     common::Trace<common::DoubleTime>::trace().flush();
 #endif
 
-                    if (_phase == SEND) {
+                    if (_phase == SEND or _phase == INIT) {
                         _phase = WAIT;
                     }
                 }
@@ -125,8 +125,7 @@ namespace artis {
 #endif
                 }
 
-                typename common::DoubleTime::type
-                start(typename common::DoubleTime::type t) override
+                void start(typename common::DoubleTime::type t) override
                 {
 
 #ifndef WITH_TRACE
@@ -141,8 +140,7 @@ namespace artis {
                                     common::LevelType::USER);
                     common::Trace<common::DoubleTime>::trace().flush();
 #endif
-                    _phase = WAIT;
-                    return 0;
+                    _phase = INIT;
                 }
 
                 typename common::DoubleTime::type
@@ -194,7 +192,7 @@ namespace artis {
 
             private:
                 enum Phase {
-                    WAIT, SEND
+                    INIT, WAIT, SEND
                 };
 
                 Phase _phase;
@@ -238,7 +236,7 @@ namespace artis {
                     common::Trace<common::DoubleTime>::trace().flush();
 #endif
 
-                    if (_phase == SEND) {
+                    if (_phase == SEND or _phase == INIT) {
                         _phase = WAIT;
                     }
                 }
@@ -290,8 +288,7 @@ namespace artis {
 
                 }
 
-                typename common::DoubleTime::type
-                start(typename common::DoubleTime::type t) override
+                void start(typename common::DoubleTime::type t) override
                 {
 
 #ifndef WITH_TRACE
@@ -308,8 +305,7 @@ namespace artis {
 #endif
 
                     _count = 0;
-                    _phase = WAIT;
-                    return 0; // std::numeric_limits<double>::max();
+                    _phase = INIT;
                 }
 
                 typename common::DoubleTime::type
@@ -362,7 +358,7 @@ namespace artis {
 
             private:
                 enum Phase {
-                    WAIT, SEND
+                    INIT, WAIT, SEND
                 };
 
                 Phase _phase;
@@ -413,8 +409,7 @@ namespace artis {
 
                 }
 
-                typename common::DoubleTime::type
-                start(typename common::DoubleTime::type t) override
+                void start(typename common::DoubleTime::type t) override
                 {
 
 #ifndef WITH_TRACE
@@ -429,8 +424,6 @@ namespace artis {
                                     common::LevelType::USER);
                     common::Trace<common::DoubleTime>::trace().flush();
 #endif
-
-                    return 0;
                 }
 
                 common::Bag<common::DoubleTime>
@@ -505,8 +498,7 @@ namespace artis {
 
                 }
 
-                typename common::DoubleTime::type
-                start(typename common::DoubleTime::type t) override
+                void start(typename common::DoubleTime::type t) override
                 {
 
 #ifndef WITH_TRACE
@@ -523,7 +515,6 @@ namespace artis {
                     common::Trace<common::DoubleTime>::trace().flush();
 #endif
 
-                    return 0;
                 }
 
                 common::Bag<common::DoubleTime>
@@ -591,7 +582,7 @@ namespace artis {
                     common::Trace<common::DoubleTime>::trace().flush();
 #endif
 
-                    if (_phase == SEND) {
+                    if (_phase == SEND or _phase == INIT) {
                         _phase = WAIT;
                     }
                 }
@@ -641,8 +632,7 @@ namespace artis {
 
                 }
 
-                typename common::DoubleTime::type
-                start(typename common::DoubleTime::type t) override
+                void start(typename common::DoubleTime::type t) override
                 {
 
 #ifndef WITH_TRACE
@@ -658,8 +648,7 @@ namespace artis {
                     common::Trace<common::DoubleTime>::trace().flush();
 #endif
 
-                    _phase = WAIT;
-                    return 0;
+                    _phase = INIT;
                 }
 
                 typename common::DoubleTime::type
@@ -712,7 +701,7 @@ namespace artis {
 
             private:
                 enum Phase {
-                    WAIT, SEND
+                    INIT, WAIT, SEND
                 };
 
                 Phase _phase;

+ 29 - 22
src/tests/mixed/tests.cpp

@@ -75,10 +75,17 @@ TEST_CASE("mixed/hierachical", "run")
                 DoubleTime > ::trace().elements().
                         filter_model_name("a1").filter_time(t).
                         filter_function_type(artis::common::FunctionType::DELTA_INT).size() == 1);
-        REQUIRE(artis::common::Trace<
-                DoubleTime > ::trace().elements().
-                        filter_model_name("a1").filter_time(t).
-                        filter_function_type(artis::common::FunctionType::TA).size() == 1);
+        if (t == 0) {
+            REQUIRE(artis::common::Trace<
+                    DoubleTime > ::trace().elements().
+                            filter_model_name("a1").filter_time(t).
+                            filter_function_type(artis::common::FunctionType::TA).size() == 2);
+        } else {
+            REQUIRE(artis::common::Trace<
+                    DoubleTime > ::trace().elements().
+                            filter_model_name("a1").filter_time(t).
+                            filter_function_type(artis::common::FunctionType::TA).size() == 1);
+        }
     }
 
     for (double t = 0; t <= 100; t = t + 3) {
@@ -91,17 +98,10 @@ TEST_CASE("mixed/hierachical", "run")
                 DoubleTime > ::trace().elements().
                         filter_model_name("b1").filter_time(t).
                         filter_function_type(artis::common::FunctionType::DELTA_INT).size() == 1);
-        if (t == 0) {
-            REQUIRE(artis::common::Trace<
-                    DoubleTime > ::trace().elements().
-                            filter_model_name("b1").filter_time(t).
-                            filter_function_type(artis::common::FunctionType::TA).size() == 1);
-        } else {
-            REQUIRE(artis::common::Trace<
-                    DoubleTime > ::trace().elements().
-                            filter_model_name("b1").filter_time(t).
-                            filter_function_type(artis::common::FunctionType::TA).size() == 2);
-        }
+        REQUIRE(artis::common::Trace<
+                DoubleTime > ::trace().elements().
+                        filter_model_name("b1").filter_time(t).
+                        filter_function_type(artis::common::FunctionType::TA).size() == 2);
         REQUIRE(artis::common::Trace<
                 DoubleTime > ::trace().elements().
                         filter_model_name("b1").filter_time(t).
@@ -122,37 +122,44 @@ TEST_CASE("mixed/hierachical", "run")
     REQUIRE(artis::common::Trace<
             DoubleTime > ::trace().elements().
                     filter_model_name("a2").filter_time(0).
-                    filter_function_type(artis::common::FunctionType::TRANSITION).at(0).get_comment()
+                    filter_function_type(artis::common::FunctionType::TRANSITION).at(
+                    0).get_comment()
                     == "x = { ( 0 , a2 , 0 ) }");
     REQUIRE(artis::common::Trace<
             DoubleTime > ::trace().elements().
                     filter_model_name("a2").filter_time(2).
-                    filter_function_type(artis::common::FunctionType::TRANSITION).at(0).get_comment()
+                    filter_function_type(artis::common::FunctionType::TRANSITION).at(
+                    0).get_comment()
                     == "x = { }");
     REQUIRE(artis::common::Trace<
             DoubleTime > ::trace().elements().
                     filter_model_name("a2").filter_time(4).
-                    filter_function_type(artis::common::FunctionType::TRANSITION).at(0).get_comment()
+                    filter_function_type(artis::common::FunctionType::TRANSITION).at(
+                    0).get_comment()
                     == "x = { ( 0 , a2 , 2 ) }");
     REQUIRE(artis::common::Trace<
             DoubleTime > ::trace().elements().
                     filter_model_name("a2").filter_time(6).
-                    filter_function_type(artis::common::FunctionType::TRANSITION).at(0).get_comment()
+                    filter_function_type(artis::common::FunctionType::TRANSITION).at(
+                    0).get_comment()
                     == "x = { }");
     REQUIRE(artis::common::Trace<
             DoubleTime > ::trace().elements().
                     filter_model_name("a2").filter_time(8).
-                    filter_function_type(artis::common::FunctionType::TRANSITION).at(0).get_comment()
+                    filter_function_type(artis::common::FunctionType::TRANSITION).at(
+                    0).get_comment()
                     == "x = { ( 0 , a2 , 3 ) }");
     REQUIRE(artis::common::Trace<
             DoubleTime > ::trace().elements().
                     filter_model_name("a2").filter_time(10).
-                    filter_function_type(artis::common::FunctionType::TRANSITION).at(0).get_comment()
+                    filter_function_type(artis::common::FunctionType::TRANSITION).at(
+                    0).get_comment()
                     == "x = { ( 0 , a2 , 4 ) }");
     REQUIRE(artis::common::Trace<
             DoubleTime > ::trace().elements().
                     filter_model_name("a2").filter_time(12).
-                    filter_function_type(artis::common::FunctionType::TRANSITION).at(0).get_comment()
+                    filter_function_type(artis::common::FunctionType::TRANSITION).at(
+                    0).get_comment()
                     == "x = { }");
 
     for (unsigned int t = 0; t <= 100; t += 2) {