Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Enum class in teshsuite/mc/random-bug/.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 18 Nov 2020 16:58:40 +0000 (17:58 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 18 Nov 2020 21:29:31 +0000 (22:29 +0100)
teshsuite/mc/random-bug/random-bug.cpp

index 76cc597..21a6313 100644 (file)
@@ -10,7 +10,7 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(random_bug, "For this example");
 
-enum { ABORT, ASSERT, PRINTF } behavior;
+enum class Behavior { ABORT, ASSERT, PRINTF } behavior;
 
 /** A fake application with a bug occurring for some random values */
 static void app()
@@ -18,12 +18,12 @@ static void app()
   int x = MC_random(0, 5);
   int y = MC_random(0, 5);
 
-  if (behavior == ASSERT) {
+  if (behavior == Behavior::ASSERT) {
     MC_assert(x != 3 || y != 4);
-  } else if (behavior == PRINTF) {
+  } else if (behavior == Behavior::PRINTF) {
     if (x == 3 && y == 4)
       XBT_ERROR("Error reached");
-  } else { // behavior == ABORT
+  } else { // behavior == Behavior::ABORT
     abort();
   }
 }
@@ -35,13 +35,13 @@ int main(int argc, char* argv[])
   xbt_assert(argc == 3, "Usage: random-bug raise|assert <platformfile>");
   if (strcmp(argv[1], "abort") == 0) {
     XBT_INFO("Behavior: abort");
-    behavior = ABORT;
+    behavior = Behavior::ABORT;
   } else if (strcmp(argv[1], "assert") == 0) {
     XBT_INFO("Behavior: assert");
-    behavior = ASSERT;
+    behavior = Behavior::ASSERT;
   } else if (strcmp(argv[1], "printf") == 0) {
     XBT_INFO("Behavior: printf");
-    behavior = PRINTF;
+    behavior = Behavior::PRINTF;
   } else {
     xbt_die("Please use either 'abort', 'assert' or 'printf' as first parameter, to specify what to do when the error "
             "is found.");