Ignore:
Timestamp:
Sep 29, 2005 11:45:32 AM (15 years ago)
Author:
dkearney
Message:
  1. cleaned up make files some more, deleted make.inc files
  2. updated RpUnits module and Cee and Fortran interfaces
  3. changed return values for some fortran interfaces,

error messages not working yet

  1. still need to add copy assignment code to RpUnits
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/src/RpUnitsC_test.c

    r40 r76  
     1//----------------------------------------------------------------------
     2// TEST: Cee's interface to RpUnits.
     3//
     4// Basic units conversion tests for the RpUnits portion of Rappture
     5// written in Cee.
     6//======================================================================
     7// AUTHOR:  Derrick Kearney, Purdue University
     8// Copyright (c) 2004-2005
     9// Purdue Research Foundation, West Lafayette, IN
     10//======================================================================
     11//
    112#include "RpUnitsCInterface.h"
    213#include <stdio.h>
     
    6374    int showUnits = 0;
    6475
    65     const char* nm_conv_str;
     76    const char* nm_conv_str = NULL;
     77    const char* retStr = NULL;
    6678   
    6779    makeMetric(meters);
     
    92104    if (nanometers) {
    93105
    94         nm_conv = convert_double_result(nanometers,meters,1.0e9,&result);
     106        nm_conv = convert_obj_double_result(nanometers,meters,1.0e9,&result);
    95107        printf("1.0e9 nm = %f m\tresult = %d\n",nm_conv,result);
    96108
    97         nm_conv = convert_double(nanometers,meters,1.0e9);
     109        nm_conv = convert_obj_double(nanometers,meters,1.0e9);
    98110        printf("1.0e9 nm = %f m\n",nm_conv);
    99111
    100112        showUnits = 1;
    101         nm_conv_str = convert_str(nanometers,meters,1.588e9,showUnits);
     113        nm_conv_str = convert_obj_str(nanometers,meters,1.588e9,showUnits);
    102114        printf("1.588e9 nm = %s\n",nm_conv_str);
    103115
    104116        showUnits = 0;
    105         nm_conv_str = convert_str(nanometers,meters,1.588e9,showUnits);
     117        nm_conv_str = convert_obj_str(nanometers,meters,1.588e9,showUnits);
    106118        printf("1.588e9 nm = %s\n",nm_conv_str);
    107119    }
     
    111123
    112124    if (meters && angstrom && centimeters) {
    113         value = convert_double_result(angstrom,meters,1.0,&result);
     125        value = convert_obj_double_result(angstrom,meters,1.0,&result);
    114126        printf("1 angstrom = %e meters\n",value);
    115127
    116         value = convert_double_result(centimeters,angstrom,1e-8,&result);
     128        value = convert_obj_double_result(centimeters,angstrom,1e-8,&result);
    117129        printf("1.0e-8 centimeter = %f angstroms\n",value);
    118130    }
     
    123135
    124136    if (fahrenheit && celcius) {
    125         value = convert_double_result(fahrenheit,celcius,72,&result);
     137        value = convert_obj_double_result(fahrenheit,celcius,72,&result);
    126138        printf("72 degrees fahrenheit = %f degrees celcius\n",value);
    127139   
    128         value = convert_double_result(celcius,fahrenheit,value,&result);
     140        value = convert_obj_double_result(celcius,fahrenheit,value,&result);
    129141        printf("22.222 degrees celcius = %f degrees fahrenheit\n",value);
    130142    }
     
    134146       
    135147    if (celcius && kelvin) {
    136         value = convert_double_result(celcius,kelvin,20,&result);
     148        value = convert_obj_double_result(celcius,kelvin,20,&result);
    137149        printf("20 degrees celcius = %f kelvin\n",value);
    138150
    139         value = convert_double_result(kelvin,celcius,300,&result);
     151        value = convert_obj_double_result(kelvin,celcius,300,&result);
    140152        printf("300 kelvin = %f degrees celcius\n", value);
    141153    }
     
    144156    }
    145157
     158    printf("====== adding all preset units ======\n");
     159    add_presets("all");
     160
     161    printf("====== TESTING STATIC CONVERT FXNS ======\n");
     162
     163    retStr = convert("72F","C",1,&result);
     164    printf("72F = %s\tresult = %d\n", retStr,result);
     165
     166    retStr = convert("300K","F",1,&result);
     167    printf("300K = %s\tresult = %d\n", retStr,result);
     168
     169    retStr = convert("1eV","J",0,&result);
     170    printf("1eV = %s (no units)\tresult = %d\n", retStr,result);
     171
     172    retStr = convert_str("300K","R",1,&result);
     173    printf("300K = %s\tresult = %d\n", retStr,result);
     174
     175    retStr = convert_str("5m","ft",1,&result);
     176    printf("5m = %s\tresult = %d\n", retStr,result);
     177
     178    value = convert_dbl("5000mV","V",&result);
     179    printf("5V = %f (double value)\n", value);
     180
     181   
    146182    return 0;
    147183}
Note: See TracChangeset for help on using the changeset viewer.