Visual C++ :: Unit-testing Functions With User-defined Types?

May 4, 2013

How can we build unit-tests for functions of libraries, those with user-defined types used as their arguments ?

For example

CRecord func(Myclass * class, BSTR * name, CComptr<xxx> & something);

View 9 Replies


ADVERTISEMENT

C/C++ :: Create User Defined Dynamic Array For Player Scores - Missing Pointer Types Error

Jan 18, 2015

I'm completely new to pointers and have a homework assignment due where I'm supposed to create a user defined dynamic array for player scores. The only errors I'm experiencing is a C2109: subscript requires pointer type and only on the lines that use the int *score; variable (57, 62, 64, 69, 71, and 82). I've already tried adding = nullptr to the variable and that didn't work.

#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
void players(string[], int[], int);
void average(int[], int);

[Code] ....

View 3 Replies View Related

C++ :: Built In Functions And User Defined?

Feb 25, 2015

what is a built in function and user defined is cause i cant seriously find a decent example about it in the net

View 4 Replies View Related

C++ :: User Defined Functions - Type Name Is Not Allowed

Dec 5, 2014

So I received an error of "type name is not allowed" and I don't know how to fix this.... Here is the code:

retrieveData(string Name, double wage, double hours, int exemptions, char Status);
dataCalculations(double wage, double hours, int exemptions, char Status, double grossPay, double ficaTax, double incomeTax, double netPay, double taxWithheld);
sendData(string Name, int ID, double hours, double wage, double ficaTax, double incomeTax, double grossPay, double netPay);

View 9 Replies View Related

C :: Testing If A Macro Is Defined To A Value?

Jan 16, 2015

Say I have something lke

Code:
#define FOO BAR
#if FOO == BAR
doX();
#else
doY();
#endif

This causes doX(); to be executed. But the intent is to have doY(); be run. I'm guessing this is because BAR is undefined and therefore blank, so blank equals blank. Is there some way to compare the symbol FOO was set to instead of its value, BAR?

View 4 Replies View Related

C++ :: User Defined Functions - Find Largest And Smallest Number

Nov 16, 2013

I am writing this code, and I every time I run question A, no matter what numbers I put in, I get "larger = 0.

#include <iostream>
using namespace std;
int awesome ();
int best ();
int crazy ();
int main () {
char letter;
int smallestNumber;
int largestNumber;

[Code] .....

View 2 Replies View Related

C :: Calculate Cost For Production Of Open Top Cylinders - User Defined Functions

Feb 20, 2013

I have this program I wrote to calculate cost for the production of open top cylinders and how to translate it into user defined functions. Here are the user defined functions I need to use instruct() get_area() comp_area() and print_area_cost() so the program will be in 4 parts.

Code:
#include <stdio.h>
int main()
{double radius,height,cost,single,all;
float surface_area;
int count;
double pi=3.14159265;
printf("Enter the radius of the base in cm^2:

[Code] ......

View 2 Replies View Related

C :: Testing Array Functions - Return Sum And Difference Of Two Matrices

Nov 10, 2013

I have these arrays in a driver to use for testing:

insert Code:

#include <stdlib.h>
#include <stdio.h>
#include "TwoD.h"
int main() {
/* Initialization of LCV's */

[Code] ....

If I want to test these functions in this header:

insert Code:

#ifndef TWOD_H_INCLUDED
#define TWOD_H_INCLUDED
#define MAX_SIZE 50
/* Structure defenition for TwoD */
typedef struct

[Code] ....

I am trying to perform columnSum and rowSum, as well as twoDadd and twoDSubtract using the arrays defined in my driver. How would I do that using A and B in my driver?

View 8 Replies View Related

C/C++ :: Testing To See If User Input Is A Number

Feb 10, 2013

I was wondering what function was the C++ equivalent for testing to see if a user input is numeric.

I have equivalents in Ruby, Java, Python, VB, VBA, php, but being a novice in C++, I have yet to find one - even with Google.

And I know C++ is such a wonderful language, that its extensive library must have one somewhere - considering it's already 2013!

View 2 Replies View Related

C++ :: Passing Types To Functions

Jan 12, 2013

I've got a game engine with a line-trace collision method which returns the first object it hits. I'd like to be able to pass it a class-type so that it can ignore objects of other types.

consider this pseudo-code:

Entity* TraceEntity( const Vec3f& LineStart, const Vec3f& LineEnd, const Type atype ) {
// check collision on entities, ignore entities of type 'atype'.
// return whatever it finds
}

I'd like to do this without template classes because it will result in a significant bloat in executable size every time I decided to trace for a new entity type (I've really developed a distaste for templates for this reason)

using type_info only checks for an object's deepest subclass, so it won't work for class C : public B : public A if I'm looking for classes of type B.

View 5 Replies View Related

C++ :: How To Write Boost Unit Test In Visual Studio 2010

Apr 16, 2014

I'm new to c++ and boost library also. I need to test a function of my library. For example

// Functions.hpp
int add(const int x, const int y);
//Functions.cpp
int add(const int x, const int y)
{
return (x + y);
}

Now i need to test add function using boost. I need the result or output in below style. What all settings do i need to do in VS 2010 and how i should include boost test in the project.

==== Run unit tests ====
Running 2 test cases...
./mytest.cpp(13): error in "SimpleTestInMainTestingModule": check 1 == 2 failed
Test suite "Master Test Suite" failed with:
1 assertion out of 2 passed
1 assertion out of 2 failed
1 test case out of 2 passed
1 test case out of 2 failed

View 1 Replies View Related

C/C++ :: Overloading Functions With Different Types (char / Int)

Apr 24, 2014

For my project, my professor is going to test each of our functions. And the functions of type string, he is going to input a value from 1-1 billion(from our calling program) and it should work. However it is not working. I tried putting in a value greater than 9, but it only prints out 1 + x. It should print whatever value I decided to input.

// COverloadingProj.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include "OverLoadingHeader.h"

[Code].....

View 5 Replies View Related

C :: User Defined Array Size

Jul 23, 2014

The instructions call for the user to define the size of the array and all I have ever done is use a predefined size for the array and then let the user fill it. Here is what I have so far:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void Display (void);
void random (int *, int);
void Ascending (int *, int);
void Descending (int *, int);

[code]....

View 7 Replies View Related

C++ :: STL Set Orderinf User Defined Objects

Mar 4, 2014

#include<iostream>
using namespace std;
#include<set>

class person{
int age;

[Code] ....

When I executed the above code it displays

Age is 37
Age is 25

Here I have defined operator< so that set can identify the order of person objects. I am clueless how set could identify that

person p[3]={person(25),person(37),person(25)};

I have provided one duplicated object with age 25

I havent overloaded == operator also,then how it could identify?

View 3 Replies View Related

C :: Return Value From User Defined Function To Main

Nov 14, 2014

I want to return value from user defined function to main.

Code:

#include <stdio.h>
int mult ( int x, int y );
int add(int x, int y);
int loop (int y);
int main() {

[Code] ......

View 1 Replies View Related

C :: User Defined Number Of Decimal Places?

Sep 2, 2013

I need the user to be able to input the number of decimal places they wish to have displayed in the output. Everything works fine as is, I just don't know how to allow for the user to input the number of decimal places they want the output to have.

Code:

#include<stdio.h>
#include<math.h>
#define PI 3.141592654
int main(void) {
//Local Declarations
int x; //desired number of decimal places
float radius; //radius of circle
float circumference; //circumference of circle

[Code] .....

View 2 Replies View Related

C++ :: Bubble Sorting With User Defined Amount Of Elements

Feb 25, 2014

I am writing some code to bubble sort a list of randoms numbers, 10 at the moment. I want to be able to user input the amount of elements that would be sorted. I think i'd have to use vector instead of arrays, but unsure how to do this. Or, how to be able to change the size of the array.

#include <iostream>
using namespace std;
#define SIZE 10

float numbers[SIZE];
int move_n;

[Code] ....

View 1 Replies View Related

C++ :: Binary Search Tree Used With User Defined Class

Nov 29, 2014

I am working on a program that uses a class I created called Student. I want to be able to add different students to a Binary Search Tree, and use the student's gpa (grade point average) to compare students with each other and place them in the correct location in the Tree.

Student class:

#ifndef STUDENT_H
#define STUDENT_H
#include <string>
#include <iostream>
#include <iomanip>
class Student{
friend ostream& operator<<(ostream& out, const Student& stu);

[Code] ......

View 3 Replies View Related

C# :: For Loops To Make User Defined V Shape Output

Jul 29, 2014

Write a program to ask a user to input a symbol from the keyboard and to output that symbol in a n X n/2 sized V where n = the width of the V. You must use a loop to process the data

I am stuck at trying to figure out how to do the actual output formatting. This is where I am sitting currently.

string character = "";
int vheight = 0;
Console.WriteLine("Enter the character you wish to use for your V: ");

[Code]....

so Im really just a bit stumped on how to get the actual V shape to be formatted..

View 14 Replies View Related

C++ :: Template Specialization Does Not Work For User-defined Object

May 23, 2014

Can you take a look why I am getting compile error.

Code:
// clang++ main.cpp -g -std=c++11 -o main
#include <iostream>
class QuoteClass {
public:
QuoteClass() = default;
QuoteClass(std::string param) {symbol = param;}
std::string get_symbol() {return symbol;}

[Code] ....

View 5 Replies View Related

C++ :: How To Assign Char Array As User Defined String Object

Apr 17, 2014

STRING s1 = “FOOBAR”

Here STRING is a user defined class. how to assign a constant char array "FOOBAR" to string object? Copy constructor need to be same class type as parameter. and overloading assignment operator also need to be same class type. I think 'friend' can let pass another type of object rather than STRING to do operation on overloaded '=' operator. How could it be done if it is possible at all?

View 2 Replies View Related

C++ :: User Defined Function - String Related Program (swapping)

Jan 4, 2015

Write a program using user-defined function which is passed a string and that function should cycle the string.(Do not use any string related functions). E.g.

If the string is : Chetna then it should print as Chetna, hetnaC, etnaCh, tnaChe,naChet, aChetn

Ans.

#include <iostream>
using namespace std;
char swamp(char a[], int x) {
for(int k=0; k<=x; k++) {
char l= a[x]; a[x]= a[0]; char p=a[x-1]; a[x-1]=l;
for(int i=1; i<x-2; i++) {

[Code]...

View 19 Replies View Related

C++ :: Object And Classes - Declaration Of Variable Using User Defined Type

Mar 17, 2013

I am getting a compilation error from the code below. It is when i am naming a variable with my user defined type.

#include<iostream>
#include<cstring>
#include<cstdlib>
using namespace std;
class person {

[Code] .....

C:Dev-CppTRIAL.PASS.!!!.cpp In function `int main()':
66 C:Dev-CppTRIAL.PASS.!!!.cpp expected primary-expression before "p"
66 C:Dev-CppTRIAL.PASS.!!!.cpp expected `;' before "p"
74 C:Dev-CppTRIAL.PASS.!!!.cpp `p' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
83 C:Dev-CppTRIAL.PASS.!!!.cpp `X' undeclared (first use this function)

View 4 Replies View Related

C++ :: Creating User Defined Function To Count Number Of Vowels

Oct 7, 2013

The output I'm getting here just counts every letter in the sentence and counts them as vowels. I'm trying to make the user defined function return the amount of vowels within the sentence.

#include <iostream>
#include <iomanip>
#include <cmath>

[Code].....

View 4 Replies View Related

C++ :: Sorting Strings / Arrays In A User Defined Lexical Order?

May 7, 2013

I previously tried to put strings in an array, but i couldn't modify the first index in the string that is in the array. I changed my code later.

[URL]

Suggest a function that sorts the inputs vertically according to the order given by the user? I made this one

void order(string order, char index[][15]){
int counter=0,line=0,i=0,j=0;
for(i=0;i<=15-1;i++)
{for(j=0;j<=15-1;j++) {
if(index[j][i]==order[counter])

[code].....

View 1 Replies View Related

C++ :: How To Add A Loop / User-defined Function And Array / Structure To Code

Apr 24, 2012

We had to write a "selling program for computers, laptops and tablets", which I did but for the extra credit, we have to have those three points in the application and I have tried but how to do the "extra credit" part, which I really need.

1.) A loop to prompt the user if they would like to place another order

2.) At least one user-defined function

3.) An enumerated data type, array or struct (structure)

I did one of these three, it's a "DO WHILE" loop asking users if they want to make another order, it's right at the beginning of the code.

Code:

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
double desktop();//function prototype
double laptop();
double tablet();

[Code] ....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved