OOP Lab Manual 01
OOP Lab Manual 01
PROGRAMMING
Lab Manual 01
Learning Outcomes
3. In the Configure your new project dialog box, select the Project Name edit box, name your new
project Starter Project, then choose to Create.
4. An empty C++ Windows console application gets created. Console applications use a Windows
console window to display output and accept user input. In Visual Studio, an empty project will be
created.
9. This is where you are going to write all your functions. Write sum() function in header file
10. You can use the functions written in the header file by including the file in Source.cpp.
11. Compile and run the code using the Local Windows Debugger option from the quick access
toolbar followed by the green play button.
Getting started with Gtest
Google test is a framework for writing C++ unit tests.
When using googletest, you start by writing assertions, which are statements that check
whether a condition is true.
Tests use assertions to verify the tested code’s behavior. If a test crashes or has a failed
assertion, then it fails; otherwise it succeeds.
A test suite contains one or many tests. You should group your tests into test suites that reflect
the structure of the tested code.
Example
Visual Studio
In Visual Studio 2017 and later, Google Test is integrated into the Visual Studio IDE as a default
component of the Desktop Development with C++ workload.
1. In Solution Explorer, right-click on the solution node and choose Add > New Project. Add a Google
Test project in Visual Studio. Click on File and create a new project
2. Search for google test and click next
3. Rename the project and click create
6. Compile and run the code using the Local Windows Debugger option from the quick access
toolbar followed by the green play button
7. After adding breakpoints, start debugging the project by clicking on Debug Icon in the Quick
Access toolbar.
8. Use step in and step out to check the value of each declared variable inside all functions.
Lab Task
G-Testing Task.
1. Write a program that has an integer array having n elements. The program should have a
function that can receive the array and then return the sum of all the elements of the
array.
Function Prototype: int sumArray(int arr[ ],int size)
2. Write a function that reverses the array using a single loop. The program should have a
function that can receive the array and then return the reverse array.
Function Prototype: int *reverseArray(int arr[ ], int size)
Task
3. Open “debugging.cpp” file and for each function, at all given breakpoints, you need to
report the values of each local variable in comments.
Submission Instructions