[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/office/alkimia/libalkimia
From:       Thomas Baumgart <thb () net-bembel ! de>
Date:       2010-10-11 11:04:54
Message-ID: 20101011110454.6D593AC7E4 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1184780 by tbaumgart:

Added unit test support

 M  +28 -0     CMakeLists.txt  
 M  +11 -1     alkvalue.h  
 A             alkvaluetest.cpp   [License: LGPL]
 A             alkvaluetest.h   [License: LGPL]


--- trunk/playground/office/alkimia/libalkimia/CMakeLists.txt #1184779:1184780
@@ -43,6 +43,17 @@
 
 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libalkimia.pc.in \
${CMAKE_CURRENT_BINARY_DIR}/libalkimia.pc IMMEDIATE @ONLY)  
+# If no build type is set, use "Release with Debug Info"
+IF(NOT CMAKE_BUILD_TYPE)
+  SET(CMAKE_BUILD_TYPE RelWithDebInfo)
+ENDIF(NOT CMAKE_BUILD_TYPE)
+
+SET(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
+  "Choose the type of build.
+Possible values are: 'Release' 'RelWithDebInfo' 'Debug' 'Debugfull' 'Profile'
+The default value is: 'RelWithDebInfo'" FORCE)
+
+
 IF(NOT WIN32)
   # use position independent code
   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
@@ -76,3 +87,20 @@
 
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libalkimia.pc
         DESTINATION ${KDE4_LIB_DIR}/pkgconfig)
+
+########### tests ###################
+
+IF( KDE4_BUILD_TESTS )
+  # INCLUDE(CTest) # (makes sense only with a ctest online dashboard)
+  ENABLE_TESTING()
+
+
+  # alkvaluetest
+  set( alkvaluetest_SRCS alkvaluetest.cpp )
+
+  kde4_add_unit_test( alkvaluetest TESTNAME alkimia-alkvalue ${alkvaluetest_SRCS} )
+  ADD_DEPENDENCIES( alkvaluetest alkimia )
+
+  target_link_libraries( alkvaluetest alkimia ${QT_QTCORE_LIBRARY} \
${QT_QTTEST_LIBRARY} ) +
+ENDIF( KDE4_BUILD_TESTS )
--- trunk/playground/office/alkimia/libalkimia/alkvalue.h #1184779:1184780
@@ -86,7 +86,7 @@
     */
   AlkValue(const QString& str, const QChar& decimalSymbol);
 
-  // explicit AlkValue( const double dAmount, const qint64 denom = 100  );
+  AlkValue(const double& dAmount);
 
   // assignment operators
   const AlkValue& operator=(const AlkValue& val);
@@ -154,13 +154,21 @@
 inline AlkValue::AlkValue(const int num, const unsigned int denom) :
   m_val(num, denom)
 {
+  m_val.canonicalize();
 }
 
 inline AlkValue::AlkValue(const mpq_class& val) :
   m_val(val)
 {
+  m_val.canonicalize();
 }
 
+inline AlkValue::AlkValue(const double& dAmount)
+{
+  m_val = dAmount;
+  m_val.canonicalize();
+}
+
 inline AlkValue AlkValue::operator+(const AlkValue& right) const
 {
   AlkValue result;
@@ -211,12 +219,14 @@
 inline const AlkValue& AlkValue::operator=(int right)
 {
   m_val = right;
+  m_val.canonicalize();
   return *this;
 }
 
 inline const AlkValue& AlkValue::operator=(double right)
 {
   m_val = right;
+  m_val.canonicalize();
   return *this;
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic