Practical Session No. 8 - CppUnit

Size: px
Start display at page:

Download "Practical Session No. 8 - CppUnit"

Transcription

1 Practical Session No. 8 - CppUnit Window, a step by step example Contents 1) Setting up your project (VC++) 2) Setting up your project (Linux) 3) The Main Program 4) Adding Tests: a) Retrieving Parameters b) Moving of Window Center c) Changing Width and Height Setting up your project (VC++) Compiling and installing CppUnit libraries The detailed description how to set your VC++ CppUnit resides at

2 In the following document, CPPUNIT is the directory where you unpacked CppUnit. It contains the directories: INCLUDE for.h files, LIB for libraries, SRC for source code etc. Before using CppUnit you need to compile CppUnit libraries; do this as follows: Open the CPPUNIT/src/CppUnitLibraries.dsw workspace in VC++. In the 'Build' menu, select 'Batch Build...' In the batch build dialog, select all projects and press the build button. The resulting libraries can be found in the CPPUNIT/lib/ directory. Once it is done, you need to let VC++ know where are the CppUnit header files and the CppUnit libraries to use them in your VC++ project note that CppUnit is not a standard library and therefore the paths to its headers and libraries are not configured Open the 'Tools/Options...' dialog, and in the 'Directories' tab, select 'include files' in the combo menu. Add a new entry that points to CPPUNIT/include/. Change to 'libraries files' in the combo and add a new entry for CPPUNIT/lib/. Repeat the process with 'source files' and add new entry CPPUNIT/src/cppunit/. Getting started Creates a new console application ('a simple application' template will do). Let's link CppUnit library to our project. In the project settings: In tab 'C++' select the combo menu 'Code generation', set the combo to 'Multithreaded DLL' for the release configuration, and 'Debug Multithreaded DLL' for the debug configure, In tab 'C++', select the combo menu 'C++ language', for All Configurations, check 'enable Run-Time Type Information (RTTI)',

3 In tab 'Link', in the 'Object/library modules' field, add cppunitd.lib for the debug configuration, and cppunit.lib for the release configuration. The CppUnit program will return 0 if all tests passed successfully, otherwise it returns the positive number n >=1 in case of error. Also, all errors are printed. You should not modify main, is serves like a "driver" for all CppUnit tests. Find environments which generate CppUnit code skeletons (main function and definitions like CPPUNIT_TEST ( )) it is a very unpleasant task so software developers may present CppUnit generators to the market. The compiler messages and the application's output is now in the build window Setting up your project (Linux) First of all, you may read the excellent guideline about how to use CppUnit on various versions of Unix: Let's assume our project consists of the following files: 1) The class being tested Window.cpp (the header file is Window.h) 2) The class containing CPPUNIT tests WindowTest.h (is implemented in WindowTest.cpp) 3) The file with main cpputest.cpp The following makefile will help us to compile the application: COMPILER = g++ cpputest : cpputest.o Window.o WindowTest.o g++ -o $@ cpputest.o Window.o WinTest.o lcppunit -ldl cpputest.o : cpputest.cpp Window.h WinTest.h $(COMPILER) o $@ -c cpputest.cpp

4 Window.o : Window.cpp Window.h WinTest.h $(COMPILER) o $@ -c Window.cpp WinTest.o : WinTest.cpp Window.h WinTest.h $(COMPILER) o $@ -c WinTest.cpp On your home Linux installations, make sure that the directories for CppUnit include files and libraries are installed properly. At the campus Linux system, CppUnit is installed properly and all the installation steps become irrelevant. Configuring Linux CppUnit installation at home: If a compiler complains it cannot find CppUnit include files, update the makefile instead of COMPILER=g++, set: COMPILER=g++ -I/users/studs/msc/binun/CppUnit/include This setting will be applied if I were installed CppUnit on my Linux account. I tells the g++ compiler where the header files of a new nonstandard package (like CppUnit) reside. If a compiler complains it cannot find CppUnit libraries, in the first row of makefile (where linking is performed), run: COMPILER=g++ -L/users/studs/msc/binun/CppUnit/lib o $@ cpputest.o Window.o WinTest.o -lcppunit -lcppunitrunner This setting tells the g++ linker where the libraries of a new nonstandard packegs (like CppUnit) reside. The main program The main function just sets the environment for running CppUnit tests. Our function is to write the class to be tested and the tests in our case, Window.h and Window.cpp represent the class Window to be tested; WinTest.h and WinTest.cpp

5 represent the tests. To make the tests available to CppUnit library, two things should be made: 1) The definition of WindowTest class should be enclosed in CPP_TEST_SUITE ( WindowTest ) CPP_TEST_SUITE_END. Between these macros, there should be several CPP_TEST ( ) macros one for each method of WindowTest 2) At the start of WindowTest.cpp there should be CPP_SUITE_TEST_REGISTRATION (WindowTest). This ensures that WindowTest class will be put into CppUnit test registry and picked by the first expression of main. The test suite picked from the test registry is loaded into CppUnit Runner object (runner.addtest (suite)). Runner is configured to direct its output (error messages due to false tests) to standard error output (console). Runner is executed using run() method. All error messages are printed; the number of false tests is returned in wassuccessful. cpputest.cpp #include <cppunit/compileroutputter.h> #include <cppunit/extensions/testfactoryregistry.h> #include <cppunit/ui/text/testrunner.h> int main(int argc, char* argv[]) // Get the top level suite from the registry CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); // Adds the test to the list of test to run CppUnit::TextUi::TestRunner runner; runner.addtest( suite ); // Change the default outputter to a stderr runner.setoutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) ); // Run the tests. bool wassuccessful = runner.run(); // Return error code 1 if the one of test failed. return wassuccessful? 0 : 1; On VC++, select Build Project (F7) to compile this file. On Linux, run the command make the makefile will run all compilation and linking steps. Then run cpputest.

6 Our application will report that everything is fine and no tests were run. So let's add some tests... Creating the Empty Window Class For this example, we are going to write a simple Window class. A window has a center, width and height: Window.h class Window private: int centerx,centery; int height,width; public: void getcenter (int&, int&); void getdimensions(int&, int&); Window(int, int, int, int); void move (int, int); ; Window.cpp #include "Window.h" void Window::getCenter (int& cx, int& cy) void Window::getDimensions(int& h, int& w) Window::Window(int cx, int cy, int h, int w) void Window::move (int byx, int byy) Let's begin by creating a test class where we can put our tests, and add single test to test retrieving of Window attributes initialized by the constructor WindowTest.h: #ifndef WINTEST_H #define WINTEST_H #include <cppunit/extensions/helpermacros.h> #include "Window.h" class WindowTest: public CppUnit::TestFixture CPPUNIT_TEST_SUITE(WindowTest); CPPUNIT_TEST( testretrieve ); CPPUNIT_TEST_EXCEPTION( testchangesize, WindowBorderException ); CPPUNIT_TEST( testmove ); CPPUNIT_TEST( testintersect ); CPPUNIT_TEST_SUITE_END(); private:

7 Window *w1,*w2; public: void setup(); void teardown(); void testretrieve(); void testchangesize (); void testmove (); ; #endif // WINTEST_H CPPUNIT_TEST_SUITE declares that our Fixture's test suite. CPPUNIT_TEST adds a method to our test suite. The test is implemented by the method named testretrieve(). setup() and teardown() are used to setup/teardown some fixtures. We are not using any for now. WindowTest.cpp #include "WindowTest.h" // Registers the fixture into the 'registry' CPPUNIT_TEST_SUITE_REGISTRATION( WindowTest ); void WindowTest::setUp() w1 = new Window (50,50,30,20); w2 = new Window (30,30,10,10); void WindowTest::tearDown() delete w1; delete w2; Void WindowTest::testRetrieve () Void WindowTest::testChangeSize() Void WindowTest::testMOve () On VC++, select Build Project (F7) to compile this file. On Linux, run the command make the makefile will run all compilation and linking steps. Then run cpputest. all tests pass, since they are empty.

8 Retrieving of Window Parameters Let's write our first real test. A test is usually composed of three parts: setting up data used by the test doing some processing based on those data checking the result of the processing void WindowTest::testRetrieve() int cx,cy; w1->getcenter(cx,cy); CPPUNIT_ASSERT_EQUAL(30,cx); CPPUNIT_ASSERT_EQUAL(20,cy); Well, we finally have a good start of what our Window class will look likes. Let's start implementing... Window.h class Window private: int centerx,centery; int height,width; public: void getcenter (int& cx, int& cy) cx = centerx; cy = centery; void getdimensions(int& h, int& w) h = height; w = width; ; Window(int cx, int cy, int h, int w) centerx = cx; centery = cy; height = h; width = w; void move (int byx, int byy)

9 On VC++, select Build Project (F7) to compile this file. On Linux, run the command make the makefile will run all compilation and linking steps. Then run cpputest. Moving of Window Center Now we want to add moving capabilities to Window. The center of the window should be moved. Note that the borders of a window should not cross the borders of the screen; if this happens, the center must remain the same. That is, the first test should pass, while the second one fail. void WindowTest::testMove () int cx,cy; w2->move (-10,-10); w2->getcenter (cx,cy); CPPUNIT_ASSERT_EQUAL(20,cx); CPPUNIT_ASSERT_EQUAL(20,cy); w1->move(35,20); int cx1, cy1; w1->getcenter(cx1, cy1); CPPUNIT_ASSERT_EQUAL(85,cx1); CPPUNIT_ASSERT_EQUAL(70,cy1); On VC++, select Build Project (F7) to compile this file. On Linux, run the command make the makefile will run all compilation and linking steps. Then run cpputest Now let's implement the required functionality: void Window::move (int byx, int byy) int top = centery + byy + height, bottom = centery + byy - height, right = centerx + byx + width, left = centerx + byx - width; if (top <= SCRHEIGHT && bottom >=0 && right <= SCRWIDTH && left >=0) centerx+=byx; centery+=byy;

10 On VC++, select Build Project (F7) to compile this file. On Linux, run the command make the makefile will run all compilation and linking steps. Then run cpputest Changing Width and Height Now let's add the capability for changing size by some factor. The center should not move; the borders will expand (or shrink, if the factor < 1). We must ensure that the new borders do not exceed the screen borders. In contrast to move (), if a border is exceeded, not only the original height and width must remain the same, but also the exception should be thrown. The tests would look like: void WindowTest::testChangeSize () int w,h; w2->enlarge(2); w2->getdimensions(w,h); CPPUNIT_ASSERT_EQUAL(20,w); CPPUNIT_ASSERT_EQUAL(20,h); w1->enlarge(2); //throws an exception... Here w2 will change the dimensions; its width and height will be (20,20). The size of w1 will be (60,40); since the center is in (50,50), the screen border will be exceeded and the exception will be thrown. Let's implement the needed functionality: void Window::enlarge (int factor) int top = centery + height*factor, bottom = centery - height*factor, right = centerx + width*factor, left = centerx - width*factor; if (top <= SCRHEIGHT && bottom >=0 && right <= SCRWIDTH && left >=0) width = width*factor; height = height*factor; else throw new WindowException; On VC++, select Build Project (F7) to compile this file. On Linux, run the command make the makefile will run all compilation and linking steps. Then run cpputest Homework (the deadline is , 24.00)

11 In this homework you will be asked to extend the example given in this practice session. You should submit the archive including: a) Makefile b) Window.cpp, Window.h - the implementation of Window class c) WindowTest.cpp, WindowTest.h - tests d) Cpputest.cpp main Your example should run in Linux. 1) The policy to change the window size in our example is implemented according to the principle "if you cannot increase the window sizes by factor 2, don't increase it at all and throw exception". However, you may increase the width and the height by the factor f smaller than required (say, 1.5) so that the window does not yet exceed the screen border. Increasing the size by the factor greater than f already leads to exceeding the screen border. We will call such f the maximal increase factor. Implement the method void Window::weak_enlarge (int factor) which tries to increase the size of a window by factor. If the resulting window exceeds the screen border, weak_enlarge computes the maximal increase factor f and increase the size of the given window by f. Write tests 2) Implement the method void Window::rotate () which rotates the window on 90 degrees (in fact, exchanges width and height). Write tests 3) Implement the method int Window::intersect (const Window &w) which checks whether the surfaces of the given window and w intersect (return 1 if yes, otherwise 0). 4) Configure the CppUnit test environment. Compile and run

Basic Design of CppUnit

Basic Design of CppUnit Basic Design of CppUnit C++ Object Oriented Programming Pei-yih Ting NTOUCS 32-1 Structurally, this is a Composite pattern. TestLeaf Test TestComposite Each TestCase is a single test. Each TestComposite

More information

CS2720 Practical Software Development

CS2720 Practical Software Development Page 1 Rex Forsyth CS2720 Practical Software Development CS2720 Practical Software Development CPPUNIT Tutorial Spring 2011 Instructor: Rex Forsyth Office: C-558 E-mail: forsyth@cs.uleth.ca Tel: 329-2496

More information

Unit Testing with JUnit and CppUnit

Unit Testing with JUnit and CppUnit Unit Testing with JUnit and CppUnit Software Testing Fundamentals (1) What is software testing? The process of operating a system or component under specified conditions, observing or recording the results,

More information

Lab 1: First Steps in C++ - Eclipse

Lab 1: First Steps in C++ - Eclipse Lab 1: First Steps in C++ - Eclipse Step Zero: Select workspace 1. Upon launching eclipse, we are ask to chose a workspace: 2. We select a new workspace directory (e.g., C:\Courses ): 3. We accept the

More information

Building And Integrating CppUnitLite in Eclipse on Linux

Building And Integrating CppUnitLite in Eclipse on Linux Building And Integrating CppUnitLite in Eclipse on Linux. If you are familiar with CppUnit, CppUnitLite is as the website mentions more barebones, lighter, and more portable as it avoids using some C++

More information

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco CS 326 Operating Systems C Programming Greg Benson Department of Computer Science University of San Francisco Why C? Fast (good optimizing compilers) Not too high-level (Java, Python, Lisp) Not too low-level

More information

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead.

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead. Chapter 9: Rules Chapter 1:Style and Program Organization Rule 1-1: Organize programs for readability, just as you would expect an author to organize a book. Rule 1-2: Divide each module up into a public

More information

CAAM 420 Daily Note. Scriber: Qijia Jiang. Date: Oct.16. Project 3 Due Wed 23.Oct. Two parts: debug code and library exercise.

CAAM 420 Daily Note. Scriber: Qijia Jiang. Date: Oct.16. Project 3 Due Wed 23.Oct. Two parts: debug code and library exercise. CAAM 420 Daily Note Scriber: Qijia Jiang Date: Oct.16 1 Announcement Project 3 Due Wed 23.Oct. Two parts: debug code and library exercise. 2 Make Convention Make syntax for library directories and library

More information

Lab 2: ADT Design & Implementation

Lab 2: ADT Design & Implementation Lab 2: ADT Design & Implementation By Dr. Yingwu Zhu, Seattle University 1. Goals In this lab, you are required to use a dynamic array to design and implement an ADT SortedList that maintains a sorted

More information

Document Revision No.: 1 Revised: 03/12/09 RIT KGCOE MSD Program. P09027 Upper Extremity Motion Capture System. Software Manual

Document Revision No.: 1 Revised: 03/12/09 RIT KGCOE MSD Program. P09027 Upper Extremity Motion Capture System. Software Manual P09027 Upper Extremity Motion Capture System Software Manual By: Melissa Gilbert, Dan Chapman, Adey Gebregiorgis, Pooja Nanda, Alan Smith and J.J Guerrette Table of contents 1 GUI USER MANUAL... 2 1.1

More information

Common Misunderstandings from Exam 1 Material

Common Misunderstandings from Exam 1 Material Common Misunderstandings from Exam 1 Material Kyle Dewey Stack and Heap Allocation with Pointers char c = c ; char* p1 = malloc(sizeof(char)); char** p2 = &p1; Where is c allocated? Where is p1 itself

More information

Tutorial on text transformation with pure::variants

Tutorial on text transformation with pure::variants Table of Contents 1. Overview... 1 2. About this tutorial... 1 3. Setting up the project... 2 3.1. Source Files... 4 3.2. Documentation Files... 5 3.3. Build Files... 6 4. Setting up the feature model...

More information

CSE 333 Autumn 2014 Midterm Key

CSE 333 Autumn 2014 Midterm Key CSE 333 Autumn 2014 Midterm Key 1. [3 points] Imagine we have the following function declaration: void sub(uint64_t A, uint64_t B[], struct c_st C); An experienced C programmer writes a correct invocation:

More information

Accept all the default choices in the Wizard's pages.

Accept all the default choices in the Wizard's pages. XLL+ Overview XLL+ is a C++ add-in which assists users in creating Excel add-in components. Two key components assist developers in creating Excel add-ins more quickly and requiring less debugging: AppWizard

More information

Check the Desktop development with C++ in the install options. You may want to take 15 minutes to try the Hello World C++ tutorial:

Check the Desktop development with C++ in the install options. You may want to take 15 minutes to try the Hello World C++ tutorial: CS262 Computer Vision OpenCV 3 Configuration with Visual Studio 2017 Prof. John Magee Clark University Install Visual Studio 2017 Community Check the Desktop development with C++ in the install options.

More information

CSCE 110 PROGRAMMING FUNDAMENTALS

CSCE 110 PROGRAMMING FUNDAMENTALS CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 15. Dictionaries (1): A Key Table Class Prof. amr Goneid, AUC 1 Dictionaries(1): A Key Table Class Prof. Amr Goneid, AUC 2 A Key Table

More information

Come and join us at WebLyceum

Come and join us at WebLyceum Come and join us at WebLyceum For Past Papers, Quiz, Assignments, GDBs, Video Lectures etc Go to http://www.weblyceum.com and click Register In Case of any Problem Contact Administrators Rana Muhammad

More information

PIC 10A. Lecture 17: Classes III, overloading

PIC 10A. Lecture 17: Classes III, overloading PIC 10A Lecture 17: Classes III, overloading Function overloading Having multiple constructors with same name is example of something called function overloading. You are allowed to have functions with

More information

Chapter 11 Introduction to Programming in C

Chapter 11 Introduction to Programming in C C: A High-Level Language Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University! Gives

More information

y

y The Unfit tutorial By Dr Martin Buist Initial version: November 2013 Unfit version: 2 or later This tutorial will show you how to write your own cost function for Unfit using your own model and data. Here

More information

Modifiers. int foo(int x) { static int y=0; /* value of y is saved */ y = x + y + 7; /* across invocations of foo */ return y; }

Modifiers. int foo(int x) { static int y=0; /* value of y is saved */ y = x + y + 7; /* across invocations of foo */ return y; } Modifiers unsigned. For example unsigned int would have a range of [0..2 32 1] on a 32-bit int machine. const Constant or read-only. Same as final in Java. static Similar to static in Java but not the

More information

1.1 The hand written header file

1.1 The hand written header file Page 1 of 8 Incorporating hand code data with generated code from 1 Overview models This paper illustrates how to integrate hand-code with the code generated from models. In particular, it will illustrate

More information

Chapter 11 Introduction to Programming in C

Chapter 11 Introduction to Programming in C C: A High-Level Language Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University Gives

More information

Chapter 11 Introduction to Programming in C

Chapter 11 Introduction to Programming in C Chapter 11 Introduction to Programming in C C: A High-Level Language Gives symbolic names to values don t need to know which register or memory location Provides abstraction of underlying hardware operations

More information

General Computer Science II Course: B International University Bremen Date: Dr. Jürgen Schönwälder Deadline:

General Computer Science II Course: B International University Bremen Date: Dr. Jürgen Schönwälder Deadline: General Computer Science II Course: 320102-B International University Bremen Date: 2004-04-28 Dr. Jürgen Schönwälder Deadline: 2004-05-14 Problem Sheet #7 This problem sheet focusses on C++ casting operators

More information

C:\Temp\Templates. Download This PDF From The Web Site

C:\Temp\Templates. Download This PDF From The Web Site 11 2 2 2 3 3 3 C:\Temp\Templates Download This PDF From The Web Site 4 5 Use This Main Program Copy-Paste Code From The Next Slide? Compile Program 6 Copy/Paste Main # include "Utilities.hpp" # include

More information

Assertions, pre/postconditions

Assertions, pre/postconditions Programming as a contract Assertions, pre/postconditions Assertions: Section 4.2 in Savitch (p. 239) Specifying what each method does q Specify it in a comment before method's header Precondition q What

More information

Exercise Session 2 Systems Programming and Computer Architecture

Exercise Session 2 Systems Programming and Computer Architecture Systems Group Department of Computer Science ETH Zürich Exercise Session 2 Systems Programming and Computer Architecture Herbstsemester 216 Agenda Linux vs. Windows Working with SVN Exercise 1: bitcount()

More information

Chapter 11 Introduction to Programming in C

Chapter 11 Introduction to Programming in C Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University C: A High-Level Language! Gives

More information

Tips from the experts: How to waste a lot of time on this assignment

Tips from the experts: How to waste a lot of time on this assignment Com S 227 Spring 2018 Assignment 1 100 points Due Date: Friday, September 14, 11:59 pm (midnight) Late deadline (25% penalty): Monday, September 17, 11:59 pm General information This assignment is to be

More information

A Fast Review of C Essentials Part II

A Fast Review of C Essentials Part II A Fast Review of C Essentials Part II Structural Programming by Z. Cihan TAYSI Outline Macro processing Macro substitution Removing a macro definition Macros vs. functions Built-in macros Conditional compilation

More information

Project structure - working with multiple les

Project structure - working with multiple les Project structure - working with multiple les Declaration and denition Recall the dierence between declaration... double max( double a, double b ); and denition... double max( double a, double b ) { if

More information

Makefiles Makefiles should begin with a comment section of the following form and with the following information filled in:

Makefiles Makefiles should begin with a comment section of the following form and with the following information filled in: CS 215 Fundamentals of Programming II C++ Programming Style Guideline Most of a programmer's efforts are aimed at the development of correct and efficient programs. But the readability of programs is also

More information

Deep C. Multifile projects Getting it running Data types Typecasting Memory management Pointers. CS-343 Operating Systems

Deep C. Multifile projects Getting it running Data types Typecasting Memory management Pointers. CS-343 Operating Systems Deep C Multifile projects Getting it running Data types Typecasting Memory management Pointers Fabián E. Bustamante, Fall 2004 Multifile Projects Give your project a structure Modularized design Reuse

More information

ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists

ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists COMP-202B, Winter 2009, All Sections Due: Tuesday, April 14, 2009 (23:55) You MUST do this assignment individually and, unless otherwise

More information

Exercise Session 2 Simon Gerber

Exercise Session 2 Simon Gerber Exercise Session 2 Simon Gerber CASP 2014 Exercise 2: Binary search tree Implement and test a binary search tree in C: Implement key insert() and lookup() functions Implement as C module: bst.c, bst.h

More information

CSE 333 Midterm Exam 5/9/14 Sample Solution

CSE 333 Midterm Exam 5/9/14 Sample Solution Question 1. (20 points) C programming. Implement the C library function strncpy. The specification of srncpy is as follows: Copy characters (bytes) from src to dst until either a '\0' character is found

More information

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011 Oregon State University School of Electrical Engineering and Computer Science CS 261 Recitation 1 Spring 2011 Outline Using Secure Shell Clients GCC Some Examples Intro to C * * Windows File transfer client:

More information

Lab 6 Due Date: Wednesday, April 5, /usr/local/3302/include/direct linking loader.h Driver File:

Lab 6 Due Date: Wednesday, April 5, /usr/local/3302/include/direct linking loader.h Driver File: Source File: ~/3302/lab06.C Specification File: /usr/local/3302/include/direct linking loader.h Driver File: /usr/local/3302/src/lab06main.c Implementation Starter File: /usr/local/3302/src/lab06.c.start

More information

Chapter 11 Introduction to Programming in C

Chapter 11 Introduction to Programming in C Chapter 11 Introduction to Programming in C C: A High-Level Language Gives symbolic names to values don t need to know which register or memory location Provides abstraction of underlying hardware operations

More information

Lecture 10. Command line arguments Character handling library void* String manipulation (copying, searching, etc.)

Lecture 10. Command line arguments Character handling library void* String manipulation (copying, searching, etc.) Lecture 10 Class string Namespaces Preprocessor directives Macros Conditional compilation Command line arguments Character handling library void* TNCG18(C++): Lec 10 1 Class string Template class

More information

12- User-Defined Material Model

12- User-Defined Material Model 12- User-Defined Material Model In this version 9.0 of Phase2 (RS 2 ), users can define their own constitutive model and integrate the model into the program by using a dynamic-linking library (dll). The

More information

Parallel System Architectures 2016 Lab Assignment 1: Cache Coherency

Parallel System Architectures 2016 Lab Assignment 1: Cache Coherency Institute of Informatics Computer Systems Architecture Jun Xiao Simon Polstra Dr. Andy Pimentel September 1, 2016 Parallel System Architectures 2016 Lab Assignment 1: Cache Coherency Introduction In this

More information

Lecture 2: C Programming Basic

Lecture 2: C Programming Basic ECE342 Introduction to Embedded Systems Lecture 2: C Programming Basic Ying Tang Electrical and Computer Engineering Rowan University 1 Facts about C C was developed in 1972 in order to write the UNIX

More information

Starting to Program in C++ (Basics & I/O)

Starting to Program in C++ (Basics & I/O) Copyright by Bruce A. Draper. 2017, All Rights Reserved. Starting to Program in C++ (Basics & I/O) On Tuesday of this week, we started learning C++ by example. We gave you both the Complex class code and

More information

Programming Assignment Multi-Threading and Debugging 2

Programming Assignment Multi-Threading and Debugging 2 Programming Assignment Multi-Threading and Debugging 2 Due Date: Friday, June 1 @ 11:59 pm PAMT2 Assignment Overview The purpose of this mini-assignment is to continue your introduction to parallel programming

More information

Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Data Types Basic Types Enumerated types The type void Derived types

More information

class Polynomial { public: Polynomial(const string& N = "no name", const vector<int>& C = vector<int>());... };

class Polynomial { public: Polynomial(const string& N = no name, const vector<int>& C = vector<int>());... }; Default Arguments 1 When declaring a C++ function, you may optionally specify a default value for function parameters by listing initializations for them in the declaration: class Polynomial { public:

More information

Obtained the source code to gcc, one can just follow the instructions given in the INSTALL file for GCC.

Obtained the source code to gcc, one can just follow the instructions given in the INSTALL file for GCC. Building cross compilers Linux as the target platform Obtained the source code to gcc, one can just follow the instructions given in the INSTALL file for GCC. configure --target=i486-linux --host=xxx on

More information

Announcements. Lecture 04b Header Classes. Review (again) Comments on PA1 & PA2. Warning about Arrays. Arrays 9/15/17

Announcements. Lecture 04b Header Classes. Review (again) Comments on PA1 & PA2. Warning about Arrays. Arrays 9/15/17 Announcements Lecture 04b Sept. 14 th, 2017 Midterm #1: Sept. 26 th (week from Tuesday) Code distributed one week from today PA2 test cases & answers posted Quiz #4 next Tuesday (before class) PA3 due

More information

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor CS 261 Fall 2017 Mike Lam, Professor C Introduction Variables, Memory Model, Pointers, and Debugging The C Language Systems language originally developed for Unix Imperative, compiled language with static

More information

Laboratory Assignment #3 Eclipse CDT

Laboratory Assignment #3 Eclipse CDT Lab 3 September 12, 2010 CS-2303, System Programming Concepts, A-term 2012 Objective Laboratory Assignment #3 Eclipse CDT Due: at 11:59 pm on the day of your lab session To learn to learn to use the Eclipse

More information

CS240: Programming in C

CS240: Programming in C CS240: Programming in C Lecture 2: Hello World! Cristina Nita-Rotaru Lecture 2/ Fall 2013 1 Introducing C High-level programming language Developed between 1969 and 1973 by Dennis Ritchie at the Bell Labs

More information

20 Using OM Access. Chapter

20 Using OM Access. Chapter Chapter 20 Using OM Access This chapter describes the OM Access feature. OM Access is a module that provides the end user with access to the information in a diagram created by the OM Editor through a

More information

Qt Introduction. Topics. C++ Build Process. Ch & Ch 3. 1) What's Qt? 2) How can we make a Qt console program? 3) How can we use dialogs?

Qt Introduction. Topics. C++ Build Process. Ch & Ch 3. 1) What's Qt? 2) How can we make a Qt console program? 3) How can we use dialogs? Topics Qt Introduction Ch 1.5 1.11 & Ch 3 1) What's Qt? 2) How can we make a Qt console program? 3) How can we use dialogs? Q: How do you pronounce Qt? A: This puppy is... 23/01/12 CMPT 212 Slides #5 Dr.

More information

Extending CircuitPython: An Introduction

Extending CircuitPython: An Introduction Extending CircuitPython: An Introduction Created by Dave Astels Last updated on 2018-11-15 11:08:03 PM UTC Guide Contents Guide Contents Overview How-To A Simple Example shared-module shared-bindings ports/atmel-samd

More information

82V391x / 8V893xx WAN PLL Device Families Device Driver User s Guide

82V391x / 8V893xx WAN PLL Device Families Device Driver User s Guide 82V391x / 8V893xx WAN PLL Device Families Device Driver Version 1.2 April 29, 2014 Table of Contents 1. Introduction... 1 2. Software Architecture... 2 2.1. Overview... 2 2.2. Hardware Abstraction Layer

More information

RECOMMENDATION. Don't Write Entire Programs Unless You Want To Spend 3-10 Times As Long Doing Labs! Write 1 Function - Test That Function!

RECOMMENDATION. Don't Write Entire Programs Unless You Want To Spend 3-10 Times As Long Doing Labs! Write 1 Function - Test That Function! 1 2 RECOMMENDATION Don't Write Entire Programs Unless You Want To Spend 3-10 Times As Long Doing Labs! Write 1 Function - Test That Function! 2 Function Overloading C++ provides the capability of Using

More information

2 2

2 2 1 2 2 3 3 C:\Temp\Templates 4 5 Use This Main Program 6 # include "Utilities.hpp" # include "Student.hpp" Copy/Paste Main void MySwap (int Value1, int Value2); int main(int argc, char * argv[]) { int A

More information

Intermediate Programming, Spring 2017*

Intermediate Programming, Spring 2017* 600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general

More information

EasyFlow - v Application Developer Guide

EasyFlow - v Application Developer Guide EasyFlow - v.0.2.1 Application Developer Guide June 23, 2014 i 2013 CAMELOT Biomedical Systems Srl. The information in this document is proprietary to CAMELOT. No part of this publication may be reproduced,

More information

C++ Coding Standards and Practices. Tim Beaudet March 23rd 2015

C++ Coding Standards and Practices. Tim Beaudet March 23rd 2015 C++ Coding Standards and Practices Tim Beaudet (timbeaudet@yahoo.com) March 23rd 2015 Table of Contents Table of contents About these standards Project Source Control Build Automation Const Correctness

More information

University of Illinois at Urbana-Champaign Department of Computer Science. First Examination

University of Illinois at Urbana-Champaign Department of Computer Science. First Examination University of Illinois at Urbana-Champaign Department of Computer Science First Examination CS 225 Data Structures and Software Principles Summer 2005 3:00pm 4:15pm Tuesday, July 5 Name: NetID: Lab Section

More information

1 of 5 3/28/2010 8:04 AM XCode Notes Home Class Info Links Lectures Newsgroup Assignmen Xcode is a free integrated development environment (IDE) for C, C++, Java and other languages on MacOS X. It comes

More information

In either case, remember to delete each array that you allocate.

In either case, remember to delete each array that you allocate. CS 103 Path-so-logical 1 Introduction In this programming assignment you will write a program to read a given maze (provided as an ASCII text file) and find the shortest path from start to finish. 2 Techniques

More information

CSCI 102L - Data Structures Midterm Exam #1 Fall 2011

CSCI 102L - Data Structures Midterm Exam #1 Fall 2011 Print Your Name: Page 1 of 8 Signature: Aludra Loginname: CSCI 102L - Data Structures Midterm Exam #1 Fall 2011 (10:00am - 11:12am, Wednesday, October 5) Instructor: Bill Cheng Problems Problem #1 (24

More information

ECE QNX Real-time Lab

ECE QNX Real-time Lab Department of Electrical & Computer Engineering Concordia University ECE QNX Real-time Lab User Guide Dan Li 9/12/2011 User Guide of ECE Real-time QNX Lab Contents 1. About Real-time QNX Lab... 2 Contacts...

More information

IMPLEMENTING SCL PROGRAMS. Using Codeblocks

IMPLEMENTING SCL PROGRAMS. Using Codeblocks IMPLEMENTING SCL PROGRAMS Using Codeblocks With the GSL on Linux Dr. José M. Garrido Department of Computer Science Updated September 2014 College of Science and Mathematics Kennesaw State University c

More information

PRINCIPLES OF OPERATING SYSTEMS

PRINCIPLES OF OPERATING SYSTEMS PRINCIPLES OF OPERATING SYSTEMS Tutorial-1&2: C Review CPSC 457, Spring 2015 May 20-21, 2015 Department of Computer Science, University of Calgary Connecting to your VM Open a terminal (in your linux machine)

More information

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM Objectives The objectives of this assignment are: to get your first experience with Java to become familiar with Eclipse Java

More information

Programming. C++ Basics

Programming. C++ Basics Programming C++ Basics Introduction to C++ C is a programming language developed in the 1970s with the UNIX operating system C programs are efficient and portable across different hardware platforms C++

More information

Exception Handling Alternatives (Part 2)

Exception Handling Alternatives (Part 2) Exception Handling Alternatives (Part 2) First published in Overload 31 Copyright 1999 Detlef Vollmann Resume In part 1, several alternative mechanisms for handling exceptional events were presented. One

More information

Chapter 1. Section 1.4 Subprograms or functions. CS 50 - Hathairat Rattanasook

Chapter 1. Section 1.4 Subprograms or functions. CS 50 - Hathairat Rattanasook Chapter 1 Section 1.4 Subprograms or functions 0 Functions Functions are essential in writing structured and well-organized code. Functions help for code to be reused. Functions help to reduce errors and

More information

HarePoint Business Cards

HarePoint Business Cards HarePoint Business Cards For SharePoint Server 2010, SharePoint Foundation 2010, Microsoft Office SharePoint Server 2007 and Microsoft Windows SharePoint Services 3.0. Product version 0.3 January 26, 2012

More information

Qt Essentials - Fundamentals of Qt Module

Qt Essentials - Fundamentals of Qt Module Qt Essentials - Fundamentals of Qt Module Qt Essentials - Training Course Produced by Nokia, Qt Development Frameworks Material based on Qt 4.7, created on December 15, 2010 http://qt.nokia.com 1/28 Module:

More information

FINAL TERM EXAMINATION SPRING 2010 CS304- OBJECT ORIENTED PROGRAMMING

FINAL TERM EXAMINATION SPRING 2010 CS304- OBJECT ORIENTED PROGRAMMING FINAL TERM EXAMINATION SPRING 2010 CS304- OBJECT ORIENTED PROGRAMMING Question No: 1 ( Marks: 1 ) - Please choose one Classes like TwoDimensionalShape and ThreeDimensionalShape would normally be concrete,

More information

For Teacher's Use Only Q No Total Q No Q No

For Teacher's Use Only Q No Total Q No Q No Student Info Student ID: Center: Exam Date: FINALTERM EXAMINATION Spring 2010 CS201- Introduction to Programming Time: 90 min Marks: 58 For Teacher's Use Only Q No. 1 2 3 4 5 6 7 8 Total Marks Q No. 9

More information

Homework 4: (GRADUATE VERSION)

Homework 4: (GRADUATE VERSION) Homework 4: Wavefront Path Planning and Path Smoothing (GRADUATE VERSION) Assigned: Thursday, October 16, 2008 Due: Friday, October 31, 2008 at 23:59:59 In this assignment, you will write a path planner

More information

COMP 202 Java in one week

COMP 202 Java in one week COMP 202 Java in one week... Continued CONTENTS: Return to material from previous lecture At-home programming exercises Please Do Ask Questions It's perfectly normal not to understand everything Most of

More information

INTERMEDIATE SOFTWARE DESIGN SPRING 2011 ACCESS SPECIFIER: SOURCE FILE

INTERMEDIATE SOFTWARE DESIGN SPRING 2011 ACCESS SPECIFIER: SOURCE FILE HEADER FILE A header (.h,.hpp,...) file contains Class definitions ( class X {... }; ) Inline function definitions ( inline int get_x() {... } ) Function declarations ( void help(); ) Object declarations

More information

Standard Version of Starting Out with C++, 4th Edition. Chapter 6 Functions. Copyright 2003 Scott/Jones Publishing

Standard Version of Starting Out with C++, 4th Edition. Chapter 6 Functions. Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 6 Functions Copyright 2003 Scott/Jones Publishing Topics 6.1 Modular Programming 6.2 Defining and Calling Functions 6.3 Function Prototypes

More information

Exiv2 - Bug #908 strerror_r gives no error message back

Exiv2 - Bug #908 strerror_r gives no error message back Exiv2 - Bug #908 strerror_r gives no error message back 18 Jun 2013 00:26 - Ákos Szőts Status: Closed Start date: 18 Jun 2013 Priority: Normal Due date: Assignee: Robin Mills % Done: 100% Category: api

More information

G52CPP C++ Programming Lecture 8. Dr Jason Atkin

G52CPP C++ Programming Lecture 8. Dr Jason Atkin G52CPP C++ Programming Lecture 8 Dr Jason Atkin 1 Last lecture Dynamic memory allocation Memory re-allocation to grow arrays Linked lists Use -> rather than. pcurrent = pcurrent -> pnext; 2 Aside: do not

More information

Symbols, Compilation Units, and Pre-Processing

Symbols, Compilation Units, and Pre-Processing Symbols, Compilation Units, and Pre-Processing Antonio Carzaniga Faculty of Informatics Università della Svizzera italiana March 2, 2015 Outline Compilation process Symbols: compilation units and linking

More information

CS342 - Spring 2019 Project #3 Synchronization and Deadlocks

CS342 - Spring 2019 Project #3 Synchronization and Deadlocks CS342 - Spring 2019 Project #3 Synchronization and Deadlocks Assigned: April 2, 2019. Due date: April 21, 2019, 23:55. Objectives Practice multi-threaded programming. Practice synchronization: mutex and

More information

QNX Software Development Platform 6.6. Quickstart Guide

QNX Software Development Platform 6.6. Quickstart Guide QNX Software Development Platform 6.6 QNX Software Development Platform 6.6 Quickstart Guide 2005 2014, QNX Software Systems Limited, a subsidiary of BlackBerry. All rights reserved. QNX Software Systems

More information

Chapter 11 Introduction to Programming in C

Chapter 11 Introduction to Programming in C Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified by Chris Wilcox, Yashwant Malaiya Colorado State University C: A High-Level Language

More information

CSE 15L Winter Midterm :) Review

CSE 15L Winter Midterm :) Review CSE 15L Winter 2015 Midterm :) Review Makefiles Makefiles - The Overview Questions you should be able to answer What is the point of a Makefile Why don t we just compile it again? Why don t we just use

More information

Homework 4 Answers. Due Date: Monday, May 27, 2002, at 11:59PM Points: 100. /* * macros */ #define SZBUFFER 1024 /* max length of input buffer */

Homework 4 Answers. Due Date: Monday, May 27, 2002, at 11:59PM Points: 100. /* * macros */ #define SZBUFFER 1024 /* max length of input buffer */ Homework 4 Answers Due Date: Monday, May 27, 2002, at 11:59PM Points: 100 UNIX System 1. (10 points) How do I delete the file i? Answer: Either rm./-i or rm -- -i will work. 2. (15 points) Please list

More information

9. Arrays. Compound Data Types: type name [elements]; int billy [5];

9. Arrays. Compound Data Types: type name [elements]; int billy [5]; - 58 - Compound Data Types: 9. Arrays An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier.

More information

CMSC 216 Introduction to Computer Systems Lecture 23 Libraries

CMSC 216 Introduction to Computer Systems Lecture 23 Libraries CMSC 216 Introduction to Computer Systems Lecture 23 Libraries Administrivia Read Sections 2.2-2.4 of Bryant and O Hallaron on data representation Make sure you copy your projects (for future reference)

More information

Macros and Preprocessor. CGS 3460, Lecture 39 Apr 17, 2006 Hen-I Yang

Macros and Preprocessor. CGS 3460, Lecture 39 Apr 17, 2006 Hen-I Yang Macros and Preprocessor CGS 3460, Lecture 39 Apr 17, 2006 Hen-I Yang Previously Operations on Linked list (Create and Insert) Agenda Linked List (More insert, lookup and delete) Preprocessor Linked List

More information

Objectives. Introduce static keyword examine syntax describe common uses

Objectives. Introduce static keyword examine syntax describe common uses Static Objectives Introduce static keyword examine syntax describe common uses 2 Static Static represents something which is part of a type rather than part of an object Two uses of static field method

More information

Excel 2016 Basics for Windows

Excel 2016 Basics for Windows Excel 2016 Basics for Windows Excel 2016 Basics for Windows Training Objective To learn the tools and features to get started using Excel 2016 more efficiently and effectively. What you can expect to learn

More information

COMsW Introduction to Computer Programming in C

COMsW Introduction to Computer Programming in C OMsW 1003-1 Introduction to omputer Programming in Lecture 9 Spring 2011 Instructor: Michele Merler http://www1.cs.columbia.edu/~mmerler/comsw1003-1.html 1 Are omputers Smarter than Humans? Link http://latimesblogs.latimes.com/technology/2011/02/ibms-watson-on-jeopardy-computer-takes-big-leadover-humans-in-round-2.html

More information

Linked List using a Sentinel

Linked List using a Sentinel Linked List using a Sentinel Linked List.h / Linked List.h Using a sentinel for search Created by Enoch Hwang on 2/1/10. Copyright 2010 La Sierra University. All rights reserved. / #include

More information

typedef Labeling<unsigned char,short> LabelingBS; typedef Labeling<unsigned char,short>::regioninfo RegionInfoBS;

typedef Labeling<unsigned char,short> LabelingBS; typedef Labeling<unsigned char,short>::regioninfo RegionInfoBS; 2005 7 19 1 ( ) Labeling 2 C++ STL(Standard Template Library) g++ (GCC) 3.3.2 3 3.1 Labeling SrcT DstT SrcT: unsigned char, shoft DstT: short typedef 1. unsigned char, short typedef Labeling

More information

Unci: a C++-based Unit-testing Framework for Intro Students

Unci: a C++-based Unit-testing Framework for Intro Students Unci: a C++-based Unit-testing Framework for Intro Students Don Blaheta Longwood University Farmville, VA, USA blahetadp@longwood.edu ABSTRACT This paper describes Unci, a unit-testing language with a

More information

Topic 6: A Quick Intro To C

Topic 6: A Quick Intro To C Topic 6: A Quick Intro To C Assumption: All of you know Java. Much of C syntax is the same. Also: Many of you have used C or C++. Goal for this topic: you can write & run a simple C program basic functions

More information

Due Date: See Blackboard

Due Date: See Blackboard Source File: ~/2315/06/lab06.(C CPP cpp c++ cc cxx cp) Input: Under control of main function Output: Under control of main function Value: 2 Extend the IntegerSet class from Lab 04 to provide the following

More information