Changeset 588

Show
Ignore:
Timestamp:
07/12/08 07:37:29 (4 months ago)
Author:
weyrick
Message:

move var-test to cppunit test, little cleanup

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/rphp/runtime/CMakeLists.txt

    r587 r588  
    1212set(RUNTIME_SRC_FILES 
    1313  rphp_hash.cpp 
     14  rphp_types.cpp 
    1415) 
    1516 
    1617add_library( rphp_runtime SHARED ${RUNTIME_SRC_FILES} ) 
    1718 
    18 # test apps 
    19 add_executable( var-test var-test.cpp ) 
    20 target_link_libraries( var-test  rphp_runtime ${ICU_LIBRARIES} ${ICU_IO_LIBRARIES} ) 
    2119 
    22  
  • trunk/rphp/runtime/rphp_types.h

    r583 r588  
    143143 
    144144 
    145 // non destructive cast (explicit copy) 
    146 pvar pvar_castToNumber(const pvar p) { 
    147  
    148     pvar r = p; 
    149     boost::apply_visitor(convertToNumber(r), r); 
    150     return r; 
    151  
    152 
    153  
    154 // TODO: belongs in rphp_operators.cpp 
    155 pvar pvar_add(const pvar lhs, const pvar rhs) 
    156 
    157     pvar l,r,result; 
    158  
    159     pvarType lhs_type = pvar_getType(lhs); 
    160     pvarType rhs_type = pvar_getType(rhs); 
    161     if ( (lhs_type == PVAR_HASH) && (rhs_type == PVAR_HASH) ) { 
    162         //std::cout << "fixme: concat hashes" << std::endl; 
    163         result = 0l; 
    164     } 
    165     else { 
    166         // convert to number, then add 
    167         l = pvar_castToNumber(lhs); 
    168         //std::cout << "pvar_add: l is " << l << std::endl; 
    169         r = pvar_castToNumber(rhs); 
    170         //std::cout << "pvar_add: r is " << r << std::endl; 
    171         result = pvar_getVal_int(l) + pvar_getVal_int(r); 
    172         //std::cout << "pvar_add: result is " << result << std::endl; 
    173     } 
    174  
    175     return result; 
    176 
     145pvar pvar_castToNumber(const pvar p); 
     146pvar pvar_add(const pvar lhs, const pvar rhs); 
    177147 
    178148 
  • trunk/rphp/runtime/test/CMakeLists.txt

    r586 r588  
    1212 
    1313# test apps 
    14 add_executable( RuntimeTestSuite Main.cpp HashTestCase.cpp ) 
    15 target_link_libraries( RuntimeTestSuite cppunit rphp_runtime ${ICU_LIBRARIES} ${ICU_IO_LIBRARIES}) 
     14add_executable( rphp_runtime_suite main.cpp phashTestCase.cpp pvarTestCase.cpp ) 
     15target_link_libraries( rphp_runtime_suite cppunit rphp_runtime ${ICU_LIBRARIES} ${ICU_IO_LIBRARIES}) 
  • trunk/rphp/runtime/test/phashTestCase.cpp

    r586 r588  
    55#include "rphp_runtime.h" 
    66 
    7 #include "HashTestCase.h" 
     7#include "phashTestCase.h" 
    88 
    9 CPPUNIT_TEST_SUITE_REGISTRATION( HashTestCase ); 
     9CPPUNIT_TEST_SUITE_REGISTRATION( phashTestCase ); 
    1010 
    11 void HashTestCase::basic() 
     11void phashTestCase::basic() 
    1212{ 
    1313    /* 
     
    3232 
    3333/* 
    34 void HashTestCase::anotherExample() 
     34void phashTestCase::anotherExample() 
    3535{ 
    3636  CPPUNIT_ASSERT (1 == 2); 
    3737} 
    3838*/ 
    39 void HashTestCase::setUp() 
     39void phashTestCase::setUp() 
    4040{ 
    4141    /* 
     
    4646 
    4747/* 
    48 void HashTestCase::testAdd() 
     48void phashTestCase::testAdd() 
    4949{ 
    5050  double result = m_value1 + m_value2; 
     
    5353 
    5454 
    55 void HashTestCase::testEquals() 
     55void phashTestCase::testEquals() 
    5656{ 
    5757  long* l1 = new long(12); 
  • trunk/rphp/runtime/test/phashTestCase.h

    r586 r588  
    11 
    2 #ifndef CPP_UNIT_EXAMPLETESTCASE_H 
    3 #define CPP_UNIT_EXAMPLETESTCASE_H 
     2#ifndef PHASHTESTCASE_H 
     3#define PHASHTESTCASE_H 
    44 
    55#include <cppunit/extensions/HelperMacros.h> 
     
    1010 */ 
    1111 
    12 class HashTestCase : public CPPUNIT_NS::TestFixture 
     12class phashTestCase : public CPPUNIT_NS::TestFixture 
    1313{ 
    14   CPPUNIT_TEST_SUITE( HashTestCase ); 
     14  CPPUNIT_TEST_SUITE( phashTestCase ); 
    1515  CPPUNIT_TEST( basic ); 
    1616  /* 
  • trunk/rphp/runtime/test/pvarTestCase.cpp

    r585 r588  
    66*/ 
    77 
     8#include <cppunit/config/SourcePrefix.h> 
     9#include <iostream> 
     10 
    811#include "rphp_runtime.h" 
    9 #include <iostream> 
     12#include "pvarTestCase.h" 
     13 
     14CPPUNIT_TEST_SUITE_REGISTRATION( pvarTestCase ); 
    1015 
    1116// generic visitor which can be applied to any pvar 
     
    7681 
    7782// driver 
    78 int main() 
     83void pvarTestCase::basic() 
    7984{ 
    8085    rphp::pvar u,t,r;