Designing and Implementing Test Code
I have searched the board and the internet with very little luck finding any good resources (ONLINE) that explain what are good practices for writing test code and how to best implement it. Granted I am sure there are many books and I am heading to the bookstore tommorow. Just wanted to know if anyone can direct me to some online resources that go a little more in depth. I am not taking any college courses. I am just doing this in my spare time. I have found extensive information about Requirments Documents and Design Documentation, commenting code practices and such but very little on how to design tests to break your code.
I am still trying to figure out what makes a good test.
Basically I am trying to develop a sense of what makes a good test. If I am not testing anything meaningful then the results mean nothing. I guess I wasn't specific in my previous post. This is probably more of a design problem then a coding one. But then again coding is design right. I am looking for design principles. I know there is black box testing and whitebox testing but i have yet to see any code examples of each really. If I am going to craft a test, how do I do it so I maximize the number of bugs I will find? I can make inefficient tests just as well as inefficient code. Maybe it just comes with practice I dunno but I was hoping to get a better handle on the subject. It seems to be a very integral part of programming but one with very little information online. Well the web is a big place. Maybe I just haven't found it yet.:rolleyes:
this is just a learning sample I did
Ok I just pulled this out of my list of learning programs it is fairly simple.
Code:
#include<iostream>
#include<string>
using namespace std;
int main()
{
char name[50];
char lastname[50];
cout <<"Please enter your name: ";
cin.getline(name,50,'\n');
if(!strcmpi("Alexander",name))
{
cout<<"That's my name too.\n";
}
else
{
cout<<"That is not my name.\n";
}
cout<<"What is your name in uppercase...\n";
strupr(name);
cout<<name<<"\n";
cout<<"And your name in lowercase...\n";
strlwr(name);
cout<<name<<"\n";
cout<<"Your name is "<<strlen(name)<<" letters long\n";
cout<<"Enter your last name: ";
cin.getline(lastname,50,'\n');
strcat(name," ");
strcat(name,lastname);
cout<<"Your full name is "<<name<<"\n";
return 0;
}
I see where the Stcat() combines both the first and last name
Stcat() causes the problem because you are trying to combine two
arrays each 50 chars into one it wont' fit and you overwrite the array.
If you want to know where I got this example it was from the tutorials on this site.