The First Lab, Logging and Functions PBV

if your not familiar with the VI editor or the linux file system here are a couple short videos
VI editor
file commands Watch the Lecuture on functions Video Watch a video about using the logging library for debuging purposes Video for all your labs and homeword assignments you will need to create a special directory Video if you do not have your login for Odin check your csub.edu (not cs.csub.edu ) email account for the remainder of this class I will not sure this email I will contact you via your cs.csub.edu email account also you will get an email there for the zoom meeting ----------------------------------------------------------------------------------- zoom information 6pm to 8:15 Join Zoom Meeting https://csub.zoom.us/j/92095637957?pwd=ZER6WU9qakJLS0Naek5aSlpMUlBiZz09 If you are not familiar with using the VI editor take 30 minutes to go through the tutor just type "vimtutor" on the command line to create your assignments directory run the following script /home/fac/msarr/public_files/create_assignments_script.sh this will prompt you for your login credentials it will then create all your directories for you homework and labs to be completed in MAKE SURE YOUR DIRECTORY HAS THE CORRECT PERMISSIONS BEFORE CONTINUING on the command line run " ls -lah ~ | grep assignments " it should not have the text student anywhere on the line that this command displays, if so stop right here and ask for help cd to the lab01 folder cd ~/assignments/cmps2020/lab/lab01/ this is where you will do your work for lab 1 copy all the files over from /home/fac/msarr/public_files/cmps2020/lab/lab01/ you can do that with the following cp -r /home/fac/msarr/public_files/cmps2020/lab/lab01/* /home/stu/YOURUSERNAME/assignments/cmps2020/lab/lab01/ or ( note the . instead of the destination folder, it means "this directory") cp -r /home/fac/msarr/public_files/cmps2020/lab/lab01/* .
File Logging is a common method of finding errors in code. Many applications that run in the background for an operating system use file logging Linux has the /var/log/ directory that contains operational logs from countless applications running right now on this server. Windows system have a built in event log and the Event Viewer application to read the logged messages. We will primarily be using logging to provide diagnostic information about the code you will be writing. there are logging functions provided for you in the cmpslib.h REQUIREMENTS: 1. You must include the logging library functions.... #include "easylogging++.h" 2. You must define the logging struct above your main.... INITIALIZE_EASYLOGGINGPP this should be done in the main file for a few reasons, it is only needed when it actually runs, not for compilation, there can be only one instance in any runable file. so ONLY put this in your main file. 3. You must include the code to set up the logfile at the start of your main and nowhere else. 4. For any files where you would like to use the logging macros or functions you will want to include "easylogging++.h" LOOK AT THE LOGGING EXAMPLES before starting this lab, the link is on the main class page File: main1.cpp


#include "cmpslib19.h" // all the special functions provided for this class


// INCLUDE THE LIBRARY FOR THE LOGGING FUNCTIONS AND THE MACRO TO INITIALIZE IT

#include "easylogging++.h"
INITIALIZE_EASYLOGGINGPP


// put your functions here

int TripleInt(int val)
  {
  LOG(INFO) << "Start " <<  __PRETTY_FUNCTION__ << endl;
  int result =  val *=3;
  LOG(INFO) << "End " <<  __PRETTY_FUNCTION__ << endl;
  return result;
  }





int main()
  {
  InitializeLogger("main1.log");



  cout << endl << endl;
  cout <<"Testing TripleInt" << endl;

  int temp;
  cout << "TripleInt(1): ";
  temp = TripleInt(1);
  if ( temp == 3 )   // test the value returned by the function to ensure it is correct  

    cout << "Pass" << endl;
  else
    cout << "Fail" << endl;

   /* 
	PassFail( bool)  is a function that returns either "Pass" or "Fail"
	depending on the expressions value
  put an exprssion that evalueates to TRUE only if your your function actually came back with the correct answer
  */

  cout << "TripleInt(3): ";
  temp = TripleInt(3);
  if ( temp == 9 ) // test the actual value returned by the function

    cout << "Pass" << endl;
  else
    cout << "Fail" << endl;

  cout << "TripleInt(0): ";
  temp = TripleInt(0);
  if ( temp == 0 ) // test the actual value returned by the function

    cout << "Pass" << endl;
  else
    cout << "Fail" << endl;

  cout << "TripleInt(-5): ";
  temp = TripleInt(-5);
  if ( temp == -15 ) // test the actual value returned by the function

    cout << "Pass" << endl;
  else
    cout << "Fail" << endl;


  // continue testing the rest of your functions

  // test LargerInt 4 times with disparate values

  // test SmallerInt 4 times with disparate values

  


  return 0;
  }
for this lab you will create some Pass By Value functions LOG THE BEGINNING AND END OF EVERY FUNCTION like the example TripleInt function LOG(INFO) << "Start " << __PRETTY_FUNCTION__ << endl; LOG(INFO) << "End " << __PRETTY_FUNCTION__ << endl; use the one completed function as a guide write and test the following two functions SmallerInt determine the smaller of two integer values passed in as parameters 1 and 2 return the result LargerInt determine the larger of two integer values passed in as parameters 1 and 2 return the result Just modify the existing main1.cpp provided for you , you will add in your functions and test them. in "main.cpp" you will test call all your functions to make sure they work properly is is 100% your responsibility to make sure that the functions you write work properly your tests should print the test "fail" if the function is not operation properly TEST EACH FUNCTION AT LEAST 4 TIMES for example BAD, do not do this TripleInt(3) calculates the value of 9 TripleInt(4) calculates the value of 12 TripleInt(-5) calculates the value of 15 GOOD TripleInt(3) PASS TripleInt(4) PASS TripleInt(-5) FAIL like the example I want you to actually store the value that the function returns compare it to the correct value that the function should return and then print pass or fail make sure your code compiles, you can test with the following make clean make ./runme1 run the example and make sure your logging is similar to the example once you are sure your code compiles, runs as expected and logs as expected you can have your lab graded for credit If you would like full credit Implement logging for the start and end ( at the very LEAST) on all your functions test each of your functions by calling them 4 times each with different values each time. if your testing the larger or smaller funcion make sure to pass in the smaller as both the first and second parameters to make sure it works in both cases. for example when testing larger 1,2 // does it work when the 2nd param is larger, should return 2 2,1 // does it work when the 1st param is larger, should return 2 2,2 // does it work when the params are the same, should return 2 -2,2 // does it work with negative numbers, should return 2 before you ask me to grade it make sure you test each function by calling it 4 times make sure you are acutally comparing the value returned by the function make sure you log the start and end both functions make sure it compiles WITHOUT warnings when you are ready for me to review your code contact me in the zoom meeting and I will review it and let you know if you need to make any changes