Browse Source

Tests: Update style of c++ code snippets in Tutorial directions

Zack Galbreath 7 years ago
parent
commit
0e2cdacf7b
2 changed files with 17 additions and 25 deletions
  1. 2 3
      Tests/Tutorial/Step1/directions.txt
  2. 15 22
      Tests/Tutorial/Step6/directions.txt

+ 2 - 3
Tests/Tutorial/Step1/directions.txt

@@ -52,14 +52,13 @@ make use of the version numbers. The resulting source code is listed below.
 
 
   int main (int argc, char *argv[])
   int main (int argc, char *argv[])
   {
   {
-    if (argc < 2)
-      {
+    if (argc < 2) {
       std::cout << argv[0] << " Version "
       std::cout << argv[0] << " Version "
                 << Tutorial_VERSION_MAJOR << "." << Tutorial_VERSION_MINOR
                 << Tutorial_VERSION_MAJOR << "." << Tutorial_VERSION_MINOR
                 << std::endl;
                 << std::endl;
       std::cout << "Usage: " << argv[0] << " number" << std::endl;
       std::cout << "Usage: " << argv[0] << " number" << std::endl;
       return 1;
       return 1;
-      }
+    }
 
 
     double inputValue = atof(argv[1]);
     double inputValue = atof(argv[1]);
 
 

+ 15 - 22
Tests/Tutorial/Step6/directions.txt

@@ -16,24 +16,21 @@ MathFunctions subdirectory a new source file named MakeTable.cxx will do just th
   int main (int argc, char *argv[])
   int main (int argc, char *argv[])
   {
   {
     // make sure we have enough arguments
     // make sure we have enough arguments
-    if (argc < 2)
-      {
+    if (argc < 2) {
       return 1;
       return 1;
-      }
+    }
 
 
     std::ofstream fout(argv[1],std::ios_base::out);
     std::ofstream fout(argv[1],std::ios_base::out);
     const bool fileOpen = fout.is_open();
     const bool fileOpen = fout.is_open();
-    if(fileOpen)
-      {
+    if(fileOpen) {
       fout << "double sqrtTable[] = {" << std::endl;
       fout << "double sqrtTable[] = {" << std::endl;
-      for (int i = 0; i < 10; ++i)
-        {
+      for (int i = 0; i < 10; ++i) {
         fout << sqrt(static_cast<double>(i)) << "," << std::endl;
         fout << sqrt(static_cast<double>(i)) << "," << std::endl;
-        }
+      }
       // close the table with a zero
       // close the table with a zero
       fout << "0};" << std::endl;
       fout << "0};" << std::endl;
       fout.close();
       fout.close();
-      }
+    }
     return fileOpen ? 0 : 1; // return 0 if wrote the file
     return fileOpen ? 0 : 1; // return 0 if wrote the file
   }
   }
 
 
@@ -81,29 +78,25 @@ found and included by mysqrt.cxx.
 Now let's use the generated table. First, modify mysqrt.cxx to include Table.h.
 Now let's use the generated table. First, modify mysqrt.cxx to include Table.h.
 Next, we can rewrite the mysqrt function to use the table:
 Next, we can rewrite the mysqrt function to use the table:
 
 
-  if (x <= 0)
-      {
-      return 0;
-      }
+  if (x <= 0) {
+    return 0;
+  }
 
 
   // use the table to help find an initial value
   // use the table to help find an initial value
   double result = x;
   double result = x;
-  if (x >= 1 && x < 10)
-    {
+  if (x >= 1 && x < 10) {
     result = sqrtTable[static_cast<int>(x)];
     result = sqrtTable[static_cast<int>(x)];
-    }
+  }
 
 
   // do ten iterations
   // do ten iterations
-  for (int i = 0; i < 10; ++i)
-    {
-    if (result <= 0)
-      {
+  for (int i = 0; i < 10; ++i) {
+    if (result <= 0) {
       result = 0.1;
       result = 0.1;
-      }
+    }
     double delta = x - (result*result);
     double delta = x - (result*result);
     result = result + 0.5*delta/result;
     result = result + 0.5*delta/result;
     std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
     std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
-    }
+  }
 
 
 Run cmake or cmake-gui to configure the project and then build it with your
 Run cmake or cmake-gui to configure the project and then build it with your
 chosen build tool. When this project is built it will first build the MakeTable
 chosen build tool. When this project is built it will first build the MakeTable