Commit ad2986db authored by Vesa Oikonen's avatar Vesa Oikonen
Browse files

added unitMultiply() with some tests

parent 335125a6
......@@ -204,6 +204,8 @@ int main(
fprintf(stderr, "failed (%d).\n", ret); return(i);}
i++; if((ret=test_unitDividerMassVolumeConversion(&status))!=0) {
fprintf(stderr, "failed (%d).\n", ret); return(i);}
i++; if((ret=test_unitMultiply(&status))!=0) {
fprintf(stderr, "failed (%d).\n", ret); return(i);}
/* statusmsg */
i++; if((ret=test_statusPrint(&status))!=0) {
......
......@@ -98,6 +98,7 @@ extern int test_unitDividerHasMass(TPCSTATUS *status);
extern int test_unitDividendHasRadioactivity(TPCSTATUS *status);
extern int test_unitCombination(TPCSTATUS *status);
extern int test_unitDividerMassVolumeConversion(TPCSTATUS *status);
extern int test_unitMultiply(TPCSTATUS *status);
/*****************************************************************************/
/*****************************************************************************/
......
......@@ -759,3 +759,56 @@ int test_unitDividerMassVolumeConversion(
/*****************************************************************************/
/*****************************************************************************/
int test_unitMultiply(
TPCSTATUS *status
) {
int verbose=0; if(status!=NULL) verbose=status->verbose;
statusSet(status, __func__, __FILE__, __LINE__, 0);
if(verbose>0) {
printf("\n=====================================\n");
printf("\n%s\n", __func__);
printf("\n=====================================\n");
}
int u, u1, u2, cu;
u1=UNIT_UNKNOWN; u2=UNIT_UNKNOWN; cu=UNIT_UNKNOWN;
u=unitMultiply(u1, u2);
if(verbose>2) printf("%s x %s -> %s\n", unitName(u1), unitName(u2), unitName(u));
if(u!=cu) return(1);
u1=UNIT_UNITLESS; u2=UNIT_UNITLESS; cu=UNIT_UNITLESS;
u=unitMultiply(u1, u2);
if(verbose>2) printf("%s x %s -> %s\n", unitName(u1), unitName(u2), unitName(u));
if(u!=cu) return(2);
u1=UNIT_UNITLESS; u2=UNIT_UNKNOWN; cu=UNIT_UNKNOWN;
u=unitMultiply(u1, u2);
if(verbose>2) printf("%s x %s -> %s\n", unitName(u1), unitName(u2), unitName(u));
if(u!=cu) return(3);
u1=UNIT_BQ_PER_ML; u2=UNIT_SEC; cu=unitIdentify("sec*Bq/mL");
u=unitMultiply(u1, u2);
if(verbose>2) printf("%s x %s -> %s\n", unitName(u1), unitName(u2), unitName(u));
if(u!=cu) return(11);
u1=UNIT_KBQ_PER_ML; u2=UNIT_MIN; cu=unitIdentify("min*kBq/mL");
u=unitMultiply(u1, u2);
if(verbose>2) printf("%s x %s -> %s\n", unitName(u1), unitName(u2), unitName(u));
if(u!=cu) return(12);
u1=UNIT_ML_PER_G; u2=UNIT_PER_MIN; cu=UNIT_ML_PER_G_MIN;
u=unitMultiply(u1, u2);
if(verbose>2) printf("%s x %s -> %s\n", unitName(u1), unitName(u2), unitName(u));
if(u!=cu) return(21);
u1=UNIT_ML_PER_G_MIN; u2=UNIT_MIN; cu=UNIT_ML_PER_G;
u=unitMultiply(u1, u2);
if(verbose>2) printf("%s x %s -> %s\n", unitName(u1), unitName(u2), unitName(u));
if(u!=cu) return(22);
return(0);
}
/*****************************************************************************/
/*****************************************************************************/
......@@ -341,6 +341,7 @@ extern int unitDividerHasMass(int u);
extern int unitDividendHasRadioactivity(int u);
extern int unitCombination(const int u1, const int u2, const int v1, const int v2);
extern int unitDividerMassVolumeConversion(int u);
extern int unitMultiply(int ua, int ub);
/*****************************************************************************/
/*****************************************************************************/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment