mardi 24 mars 2015

Google test, how to use template in test code, to check types

I am trying to write a unit test case for the below function.



SQLSMALLINT type_conversion_fn(InputType xtype) {
switch (xtype) {
case XSQL_String:
return SQL_TINYINT;

default:
return SQL_WVARCHAR;
}
}


So my google test file:



#include "gtest/gtest.h"
#include "blabla.hh"

InputType xsql_type;

TEST(xsql, test_type_conversion_fn) {
SQLSMALLINT result;
inputType = XSQL_String;
result = type_conversion_fn(inputType);
EXPECT_TRUE(::testing::StaticAssertTypeEq<SQL_WVARCHAR, result>());

}


I am getting too many errors... The template function is in the documentation http://ift.tt/1BkJ8UE


I think for the unit testing, I need to check for the return type matches? So I looked for assert type, and reached the google documentation link. But I do not know how to apply it to my code... Please help. Thank you.


Aucun commentaire:

Enregistrer un commentaire