lundi 24 août 2015

how to test void function using google test?

I have the following code:

typedef struct
{
  int age;
  int number;
} Data;

bool selectToDatabase(Data* data)
{
   // use SQL to insert to database,
   // if succeed, return true,
   // if not, return false 
}

void formData()
{
   Data data[3];

   data[0].age    = 10;
   data[0].number = 10;

   data[1].age    = 20;
   data[1].number = 20;

   data[2].age    = 30;
   data[2].number = 30;

   selectToDatabase(data);       
}

I am test the formData() using google test, I want to verify if the data array within the formData() is formed correctly or not, are there anyway to check it?

Aucun commentaire:

Enregistrer un commentaire