Compare commits
27 Commits
0ce6afa43c
...
648c2e491e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
648c2e491e | ||
|
|
d5da2e7c7f | ||
|
|
04da5daa41 | ||
|
|
9505669780 | ||
|
|
f72d4bcda4 | ||
|
|
7948028022 | ||
|
|
4307890356 | ||
|
|
7312fa9a36 | ||
|
|
d255224822 | ||
|
|
49507b4a84 | ||
|
|
3092f4f45b | ||
|
|
6e100e19f5 | ||
| 740d38ccce | |||
|
|
33d1abd14c | ||
|
|
14e13fa8c1 | ||
|
|
3f84598ec0 | ||
|
|
1646f1ada7 | ||
|
|
3a4ac8badd | ||
| 05b48af153 | |||
| b11ebc8100 | |||
| e6bc9638e7 | |||
| 00321257b4 | |||
| b0c98d4464 | |||
| 410bc42830 | |||
| 2511e96372 | |||
| 5ef37dc7fd | |||
| a9e6ed0753 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
||||
/.svn
|
||||
/doc/rtf
|
||||
_unsused
|
||||
CMakeLists.txt.user
|
||||
150
CMakeLists.txt
150
CMakeLists.txt
@@ -1,46 +1,36 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
||||
project(pip)
|
||||
set(_PIP_MAJOR 2)
|
||||
set(_PIP_MINOR 5)
|
||||
set(_PIP_REVISION 0)
|
||||
set(_PIP_SUFFIX _beta)
|
||||
set(_PIP_COMPANY SHS)
|
||||
set(_PIP_DOMAIN org.SHS)
|
||||
set(pip_MAJOR 2)
|
||||
set(pip_MINOR 5)
|
||||
set(pip_REVISION 0)
|
||||
set(pip_SUFFIX _beta)
|
||||
set(pip_COMPANY SHS)
|
||||
set(pip_DOMAIN org.SHS)
|
||||
|
||||
if ("x${CMAKE_MODULE_PATH}" STREQUAL "x")
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
endif()
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(PIP_BUILD 1)
|
||||
include(CheckFunctionExists)
|
||||
include(GenerateExportHeader)
|
||||
include(DeployMacros)
|
||||
include(PIPMacros)
|
||||
if(NOT DEFINED BUILD_NUMBER)
|
||||
set(BUILD_NUMBER 9999)
|
||||
endif()
|
||||
if("x${BUILD_NUMBER}" STREQUAL "x")
|
||||
set(BUILD_NUMBER 0)
|
||||
endif()
|
||||
include(SHSTKMacros)
|
||||
|
||||
shstk_begin_project(pip PIP)
|
||||
|
||||
set(_ICU_DEFAULT OFF)
|
||||
if((NOT DEFINED WIN32) AND (NOT DEFINED ANDROID_PLATFORM) AND (NOT DEFINED APPLE))
|
||||
set(_ICU_DEFAULT ON)
|
||||
endif()
|
||||
set(PIP_DLL_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE STRING "")
|
||||
|
||||
|
||||
# Options
|
||||
option(ICU "ICU support for convert codepages" ${_ICU_DEFAULT})
|
||||
option(STD_IOSTREAM "Building with std iostream operators support" OFF)
|
||||
option(INTROSPECTION "Build with introspection" OFF)
|
||||
option(LIB "System install" ON)
|
||||
option(STATIC_LIB OFF)
|
||||
option(TESTS "Build tests and perform their before install step" OFF)
|
||||
set(PIP_UTILS 1)
|
||||
if(LIBPROJECT)
|
||||
set(PIP_UTILS ${UTILS})
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
@@ -69,7 +59,7 @@ macro(pip_module NAME LIBS LABEL INCLUDES MSG)
|
||||
file(GLOB_RECURSE CPPS "libs/${NAME}/*.cpp")
|
||||
file(GLOB_RECURSE HS "libs/${NAME}/*.h")
|
||||
file(GLOB_RECURSE PHS "libs/${NAME}/*_p.h")
|
||||
file(GLOB_RECURSE RES "libs/${NAME}/*conf.h")
|
||||
file(GLOB_RECURSE RES "libs/${NAME}/*.conf")
|
||||
list(REMOVE_ITEM HS "${PHS}")
|
||||
list(APPEND HDRS ${HS})
|
||||
list(APPEND PHDRS ${PHS})
|
||||
@@ -84,11 +74,11 @@ macro(pip_module NAME LIBS LABEL INCLUDES MSG)
|
||||
string(TOUPPER "${_target}" DEF_NAME)
|
||||
|
||||
set(PIP_MSG_${NAME} "yes${MSG}")
|
||||
import_version(${_target} PIP)
|
||||
set_deploy_property(${_target} ${PIP_LIB_TYPE}
|
||||
import_version(${_target} pip)
|
||||
set_deploy_property(${_target} ${pip_LIB_TYPE}
|
||||
LABEL "${LABEL}"
|
||||
FULLNAME "${_PIP_DOMAIN}.${_target}"
|
||||
COMPANY "${_PIP_COMPANY}"
|
||||
FULLNAME "${pip_DOMAIN}.${_target}"
|
||||
COMPANY "${pip_COMPANY}"
|
||||
INFO "Platform-Independent Primitives")
|
||||
make_rc(${_target} _RC)
|
||||
|
||||
@@ -101,21 +91,22 @@ macro(pip_module NAME LIBS LABEL INCLUDES MSG)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if (NOT "${RES}" STREQUAL "")
|
||||
if (NOT "x${RES}" STREQUAL "x")
|
||||
pip_resources(CRES "${RES}")
|
||||
endif()
|
||||
add_definitions(-D${DEF_NAME})
|
||||
add_library(${_target} ${PIP_LIB_TYPE} ${CPPS} ${CRES} ${_RC})
|
||||
if (NOT "${RES}" STREQUAL "")
|
||||
add_library(${_target} ${pip_LIB_TYPE} ${CPPS} ${CRES} ${_RC})
|
||||
target_include_directories(${_target} PUBLIC ${PIP_INCLUDES})
|
||||
if (NOT "x${RES}" STREQUAL "x")
|
||||
add_dependencies(${_target} pip_rc)
|
||||
endif()
|
||||
if (NOT "${INCLUDES}" STREQUAL "")
|
||||
if (NOT "x${INCLUDES}" STREQUAL "x")
|
||||
target_include_directories(${_target} PRIVATE ${INCLUDES})
|
||||
endif()
|
||||
list(APPEND PIP_EXPORTS "${DEF_NAME}_EXPORT")
|
||||
target_link_libraries(${_target} ${LINK_LIBS})
|
||||
list(APPEND PIP_MODULES ${_target})
|
||||
if (NOT "${LIBS}" STREQUAL "")
|
||||
if (NOT "x${LIBS}" STREQUAL "x")
|
||||
list(APPEND LIBS_STATUS ${LIBS})
|
||||
endif()
|
||||
endmacro()
|
||||
@@ -132,63 +123,10 @@ if (DEFINED ENV{QNX_HOST} OR PIP_FREERTOS)
|
||||
set(STATIC_LIB ON)
|
||||
endif()
|
||||
|
||||
if(STATIC_LIB)
|
||||
set(PIP_LIB_TYPE STATIC)
|
||||
set(PIP_LIB_TYPE_MSG "Static")
|
||||
add_definitions(-DPIP_STATIC_DEFINE)
|
||||
else()
|
||||
set(PIP_LIB_TYPE SHARED)
|
||||
set(PIP_LIB_TYPE_MSG "Shared")
|
||||
endif()
|
||||
|
||||
|
||||
# Version
|
||||
set_version(PIP
|
||||
MAJOR "${_PIP_MAJOR}"
|
||||
MINOR "${_PIP_MINOR}"
|
||||
REVISION "${_PIP_REVISION}"
|
||||
BUILD "${BUILD_NUMBER}"
|
||||
SUFFIX "${_PIP_SUFFIX}"
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/piversion.h")
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h")
|
||||
file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h")
|
||||
endif()
|
||||
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/piversion.h")
|
||||
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_version.h")
|
||||
|
||||
if(MINGW)
|
||||
find_package(MinGW REQUIRED)
|
||||
list(APPEND CMAKE_LIBRARY_PATH ${MINGW_LIB})
|
||||
else()
|
||||
if(APPLE)
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
set(CMAKE_INSTALL_NAME_DIR "@rpath")
|
||||
else()
|
||||
include_directories(/usr/local/include)
|
||||
link_directories(/usr/local/lib)
|
||||
endif()
|
||||
set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks;@executable_path/lib;@loader_path/../lib")
|
||||
set(CMAKE_MACOSX_RPATH 1)
|
||||
else()
|
||||
set(CMAKE_INSTALL_RPATH "\$ORIGIN;\$ORIGIN/lib")
|
||||
endif()
|
||||
endif()
|
||||
if(LIB)
|
||||
if(WIN32)
|
||||
if(MINGW)
|
||||
set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
|
||||
endif()
|
||||
else()
|
||||
if (DEFINED ANDROID_PLATFORM)
|
||||
set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr)
|
||||
else()
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
set(CMAKE_INSTALL_PREFIX ${CMAKE_STAGING_PREFIX})
|
||||
else()
|
||||
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr/local)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED PIP_CMG)
|
||||
if (CMAKE_CROSSCOMPILING OR (DEFINED ANDROID_PLATFORM))
|
||||
@@ -210,16 +148,13 @@ get_filename_component(C_COMPILER "${CMAKE_C_COMPILER}" NAME)
|
||||
# Main lib
|
||||
file(GLOB PIP_FOLDERS LIST_DIRECTORIES TRUE "${CMAKE_CURRENT_SOURCE_DIR}/libs/main/*")
|
||||
list(APPEND PIP_FOLDERS "${CMAKE_CURRENT_SOURCE_DIR}/libs/main")
|
||||
set(PIP_MAIN_FOLDERS)
|
||||
set(PIP_INCLUDES "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
foreach(F ${PIP_FOLDERS})
|
||||
if (IS_DIRECTORY "${F}")
|
||||
list(APPEND PIP_MAIN_FOLDERS "${F}")
|
||||
include_directories("${F}")
|
||||
list(APPEND PIP_INCLUDES "${F}")
|
||||
#include_directories("${F}")
|
||||
endif()
|
||||
endforeach(F)
|
||||
if (DEFINED LIBPROJECT)
|
||||
set(PIP_MAIN_FOLDERS "${PIP_MAIN_FOLDERS}" PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
if (TESTS)
|
||||
set(PIP_ROOT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
@@ -229,7 +164,7 @@ endif()
|
||||
if(PIP_FREERTOS)
|
||||
add_definitions(-DPIP_FREERTOS)
|
||||
set(ICU OFF)
|
||||
set(LIB OFF)
|
||||
set(LOCAL ON)
|
||||
endif()
|
||||
|
||||
# Check Bessel functions
|
||||
@@ -365,7 +300,6 @@ else()
|
||||
pip_find_lib(${LIB_})
|
||||
endforeach()
|
||||
endif()
|
||||
import_version(pip PIP)
|
||||
if(WIN32)
|
||||
add_definitions(-DPSAPI_VERSION=1)
|
||||
if(${C_COMPILER} STREQUAL "cl.exe")
|
||||
@@ -510,16 +444,16 @@ if (NOT CROSSTOOLS)
|
||||
set(PIP_MSG_compress "yes")
|
||||
set(PIP_MODULES pip)
|
||||
add_definitions(-DPIP_CRYPT)
|
||||
add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT})
|
||||
add_library(pip_crypt ${pip_LIB_TYPE} ${CPP_LIB_CRYPT})
|
||||
target_link_libraries(pip_crypt pip)
|
||||
list(APPEND PIP_MODULES pip_crypt)
|
||||
set(IO_UTILS_LIBS pip)
|
||||
add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS})
|
||||
add_library(pip_io_utils ${pip_LIB_TYPE} ${CPP_LIB_IO_UTILS})
|
||||
list(APPEND IO_UTILS_LIBS pip_crypt)
|
||||
target_link_libraries(pip_io_utils ${IO_UTILS_LIBS})
|
||||
list(APPEND PIP_MODULES pip_io_utils)
|
||||
add_definitions(-DPIP_COMPRESS)
|
||||
add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS})
|
||||
add_library(pip_compress ${pip_LIB_TYPE} ${CPP_LIB_COMPRESS})
|
||||
target_link_libraries(pip_compress pip)
|
||||
list(APPEND PIP_MODULES pip_compress)
|
||||
|
||||
@@ -531,7 +465,7 @@ target_compile_definitions(pip PRIVATE "PICODE_DEFINES=\"${PIP_EXPORTS_STR}\"")
|
||||
|
||||
# Install
|
||||
# Check if system or local install will be used (to system install use "-DLIB=" argument of cmake)
|
||||
if(LIB)
|
||||
if(NOT LOCAL)
|
||||
if(WIN32)
|
||||
if(MINGW)
|
||||
if (NOT CROSSTOOLS)
|
||||
@@ -562,8 +496,6 @@ if(LIB)
|
||||
endif()
|
||||
install(TARGETS ${PIP_MODULES} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
||||
endif()
|
||||
file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in" "cmake/android_debug.keystore")
|
||||
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
|
||||
else()
|
||||
if(NOT PIP_FREERTOS)
|
||||
if(WIN32)
|
||||
@@ -578,6 +510,8 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in")
|
||||
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
|
||||
|
||||
if(NOT PIP_FREERTOS)
|
||||
|
||||
@@ -603,11 +537,9 @@ if(NOT PIP_FREERTOS)
|
||||
endif()
|
||||
|
||||
|
||||
# Libraries messages
|
||||
if(DEFINED LIBPROJECT)
|
||||
shstk_is_parent_exists(_pe)
|
||||
if (_pe)
|
||||
set(PIP_MODULES ${PIP_MODULES} PARENT_SCOPE)
|
||||
list(APPEND _ALL_TARGETS ${PIP_MODULES})
|
||||
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
#
|
||||
@@ -617,9 +549,9 @@ if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
|
||||
include(PIPDocumentation)
|
||||
find_package(Doxygen)
|
||||
if(DOXYGEN_FOUND)
|
||||
set(DOXY_PROJECT_NUMBER "${PIP_VERSION}")
|
||||
set(DOXY_QHP_CUST_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"")
|
||||
set(DOXY_QHP_SECT_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"")
|
||||
set(DOXY_PROJECT_NUMBER "${pip_VERSION}")
|
||||
set(DOXY_QHP_CUST_FILTER_ATTRS "\"PIP ${pip_VERSION}\"")
|
||||
set(DOXY_QHP_SECT_FILTER_ATTRS "\"PIP ${pip_VERSION}\"")
|
||||
set(DOXY_EXAMPLE_PATH "\"${CMAKE_CURRENT_SOURCE_DIR}/doc/examples\"")
|
||||
set(DOXY_IMAGE_PATH "\"${CMAKE_CURRENT_SOURCE_DIR}/doc/images\"")
|
||||
set(DOXY_EXCLUDE "\"${CMAKE_CURRENT_SOURCE_DIR}/libs/lua/3rd\"")
|
||||
@@ -662,10 +594,10 @@ endmacro()
|
||||
|
||||
list(REMOVE_ITEM LIBS_STATUS ${PIP_MODULES})
|
||||
message("----------PIP----------")
|
||||
message(" Version: ${PIP_VERSION} ")
|
||||
message(" Linkage: ${PIP_LIB_TYPE_MSG}")
|
||||
message(" Type : ${PIP_BUILD_TYPE}")
|
||||
if(LIB)
|
||||
message(" Version: ${pip_VERSION} ")
|
||||
message(" Linkage: ${pip_LIB_TYPE_MSG}")
|
||||
message(" Type : ${pip_BUILD_TYPE}")
|
||||
if (NOT LOCAL)
|
||||
message(" Install: \"${CMAKE_INSTALL_PREFIX}\"")
|
||||
else()
|
||||
if(NOT PIP_FREERTOS)
|
||||
|
||||
@@ -1,1076 +0,0 @@
|
||||
#[[
|
||||
|
||||
Important! You should include this file
|
||||
in your top-level CMakeLists.txt
|
||||
|
||||
|
||||
|
||||
|
||||
set_version(<target> [MAJOR <value>] [MINOR <value>] [REVISION <value>] [SUFFIX <value>] [BUILD <value>] [OUTPUT <file>])
|
||||
|
||||
Set target version, optionally creates file
|
||||
|
||||
Create variable <target>_VERSION with full version name
|
||||
|
||||
If OUTPUT then generate header <file> with
|
||||
version macros - <target>_VERSION_<NAME>
|
||||
Also create macro <target>_VERSION_NAME with full string version and
|
||||
macro <target>_MAKE_VERSION(major, minor, revision) that returns
|
||||
byte-packed integer version.
|
||||
Attention: macro <target>_VERSION is byte-packed integer version!
|
||||
|
||||
|
||||
|
||||
|
||||
set_lang(<target> <lang> [<lang> [...] ])
|
||||
|
||||
Set target translations, e.g. "ru" "fr"
|
||||
|
||||
|
||||
|
||||
|
||||
import_version(<target> <source_target>)
|
||||
|
||||
Copy all version components and languages from <source_target>
|
||||
|
||||
|
||||
|
||||
|
||||
import_deploy_properties(<target> <source_target>)
|
||||
|
||||
Copy all deploy properties from <source_target>
|
||||
|
||||
|
||||
|
||||
|
||||
set_deploy_property(<target> [SHARED | STATIC] NAME <value> [NAME <value> [...] ])
|
||||
|
||||
Set target deploy property, where NAME one of:
|
||||
* LABEL - application icon name
|
||||
* FULLNAME - package name in format "*.*.*"
|
||||
* COMPANY - company name
|
||||
* ICON - icon file path
|
||||
* INFO - additional info
|
||||
|
||||
Specify SHARED or STATIC if your target is library
|
||||
You can setup several properties in one command
|
||||
|
||||
|
||||
|
||||
|
||||
make_rc(<target> <rc_out_file>)
|
||||
|
||||
Generate Windows *.rc file from deploy properties
|
||||
and return file path to <rc_out_file>
|
||||
On other platforms this variable set to empty
|
||||
|
||||
You should set version and deploy properties
|
||||
before call this macro, see
|
||||
"set_version()" and "set_deploy_property()"
|
||||
|
||||
|
||||
|
||||
|
||||
deploy_target(<target> [DEPLOY_DIR <dir>]
|
||||
[DESTINATION <dir>]
|
||||
[RESOURCES <dir|file> [<dir|file> ...] ]
|
||||
[PLUGINS <dir|file> [<dir|file> ...] ]
|
||||
[FILES <dir|file> [<dir|file> ...] ]
|
||||
[LIBS <dir|file> [<dir|file> ...] ]
|
||||
[OPTIONS <flag> ...]
|
||||
[VERBOSE]
|
||||
[DMG_NO_ZIP]
|
||||
[DEB_USR_DIR] [DEB_ADD_SERVICE])
|
||||
|
||||
Create make target "deploy_<target>", depends on target "deploy".
|
||||
On this target create release package, containing all dependencies:
|
||||
* .zip on Windows
|
||||
* .deb on Linux
|
||||
* .dmg[.zip] on MacOS
|
||||
* .apk/.aab on Android
|
||||
If not defined DMG_NO_ZIP then *.dmg.zip will be created on MacOS.
|
||||
|
||||
You should set version and deploy properties
|
||||
before call this macro, see
|
||||
"set_version()" and "set_deploy_property()".
|
||||
|
||||
Example:
|
||||
deploy_target(my_app DESTINATION packages)
|
||||
|
||||
|
||||
DEPLOY_DIR - dir where you install
|
||||
* executable on Windows, Linux
|
||||
* <T>.app directory with executable on MacOS
|
||||
|
||||
DESTINATION - dir where macro place package
|
||||
|
||||
RESOURCES, PLUGINS and FILES - list of directories and files, copied to:
|
||||
|
||||
| | Windows | Linux | Linux (DEB_USR_DIR) | MacOS |
|
||||
|-----------|---------|-------------------------|---------------------------|---------------------|
|
||||
| RESOURCES | root | /opt/COMPANY/target | /usr/share/COMPANY/target | Contents/Resources |
|
||||
| PLUGINS | root | /opt/COMPANY/target | /usr/lib/COMPANY/target | Contents/PlugIns |
|
||||
| FILES | root | /opt/COMPANY/target | /usr/bin | Contents/MacOS |
|
||||
| LIBS | root | /opt/COMPANY/target/lib | /usr/lib | Contents/Frameworks |
|
||||
|
||||
Relative paths are taken from DEPLOY_DIR
|
||||
Also check library dependencies from PLUGINS and FILES
|
||||
Important! RESOURCES, PLUGINS, FILES and LIBS lists check
|
||||
at cmake-time, so if entry ends with "/" it treat
|
||||
as directory, else - file
|
||||
|
||||
|
||||
This macro using "deploy_tool" from PIP,
|
||||
so make sure it can be executed from shell
|
||||
OPTIONS allow you to pass custom flags to "deploy_tool"
|
||||
You can see flags by launch "deploy_tool" without arguments
|
||||
|
||||
Using CMAKE_LDD, CMAKE_OTOOL or CMAKE_OBJDUMP variable,
|
||||
depends on target platform
|
||||
|
||||
DEPLOY_ADD_LIBPATH variable used as additional
|
||||
library search path
|
||||
|
||||
If DEB_ADD_SERVICE then <T>-service.deb package will be created.
|
||||
This package use contents of CMAKE_CURRENT_SOURCE_DIR/debian-service directory:
|
||||
* CMAKE_CURRENT_SOURCE_DIR/debian-service/DEBIAN/
|
||||
* CMAKE_CURRENT_SOURCE_DIR/debian-service/*.service
|
||||
.service file placed in /opt/COMPANY/target, you should copy it to system with script
|
||||
You can use "postinst,postrm,preinst,prerm,config" files to configure service
|
||||
|
||||
]]
|
||||
|
||||
|
||||
cmake_policy(SET CMP0011 NEW) # don`t affect includer policies
|
||||
if (POLICY CMP0057)
|
||||
cmake_policy(SET CMP0057 NEW) # Support if() IN_LIST
|
||||
endif()
|
||||
if (POLICY CMP0053)
|
||||
cmake_policy(SET CMP0053 NEW)
|
||||
endif()
|
||||
set(__prop_names "LABEL;FULLNAME;COMPANY;ICON;INFO")
|
||||
list(APPEND __prop_names "ANDROID_TARGET_SDK;ANDROID_STORE_FILE;ANDROID_STORE_PASSWORD;ANDROID_KEY_PASSWORD;ANDROID_KEY_ALIAS;ANDROID_NEW_LOADER")
|
||||
set(__version_names "MAJOR;MINOR;REVISION;BUILD;SUFFIX")
|
||||
include(TargetArch)
|
||||
if (NOT MY_ARCH)
|
||||
target_architecture(MY_ARCH)
|
||||
endif()
|
||||
if (NOT _dep_exists)
|
||||
set(_dep_exists 1)
|
||||
add_custom_target(deploy COMMENT "Deploy")
|
||||
endif()
|
||||
set(_modules_dir "${CMAKE_ROOT}/Modules")
|
||||
if (LIBPROJECT)
|
||||
set(_modules_dir ${PIP_CMAKE_MODULE_PATH})
|
||||
endif()
|
||||
set(_dt_delim "::")
|
||||
|
||||
|
||||
macro(set_version _T)
|
||||
set(_VERSION_ 2) # macro version
|
||||
set(_name)
|
||||
set(_is_name 1)
|
||||
set(_is_out 0)
|
||||
set(_out)
|
||||
#message("set_version \"${_T}\"")
|
||||
foreach(_i ${ARGN})
|
||||
if (_is_out)
|
||||
set(_is_out 0)
|
||||
set(_out "${_i}")
|
||||
elseif ("x${_i}" STREQUAL "xOUTPUT")
|
||||
set(_is_out 1)
|
||||
elseif(_is_name)
|
||||
#message("set_version component \"${_i}\"")
|
||||
set(_is_name 0)
|
||||
if (_i IN_LIST __version_names)
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid version component \"${_i}\"!")
|
||||
endif()
|
||||
set(_name ${_i})
|
||||
set(${_T}_VERSION_${_name})
|
||||
else()
|
||||
#message("set_version value \"${_name}\" = \"${_i}\"")
|
||||
set(_is_name 1)
|
||||
set(${_T}_VERSION_${_name} ${_i})
|
||||
endif()
|
||||
endforeach()
|
||||
set(${_T}_VERSION_FULLSUFFIX "${${_T}_VERSION_SUFFIX}")
|
||||
if (NOT ("x${${_T}_VERSION_FULLSUFFIX}" STREQUAL "x"))
|
||||
if(NOT ("${${_T}_VERSION_FULLSUFFIX}" MATCHES "_.*"))
|
||||
set(${_T}_VERSION_FULLSUFFIX "_${${_T}_VERSION_FULLSUFFIX}")
|
||||
endif()
|
||||
endif()
|
||||
if ("x${${_T}_VERSION_MAJOR}" STREQUAL "x")
|
||||
set(${_T}_VERSION_MAJOR "0")
|
||||
endif()
|
||||
if ("x${${_T}_VERSION_MINOR}" STREQUAL "x")
|
||||
set(${_T}_VERSION_MINOR "0")
|
||||
endif()
|
||||
if ("x${${_T}_VERSION_REVISION}" STREQUAL "x")
|
||||
set(${_T}_VERSION_REVISION "0")
|
||||
endif()
|
||||
if ("x${${_T}_VERSION_BUILD}" STREQUAL "x")
|
||||
set(${_T}_VERSION_BUILD "0")
|
||||
endif()
|
||||
set(${_T}_VERSION "${${_T}_VERSION_MAJOR}.${${_T}_VERSION_MINOR}.${${_T}_VERSION_REVISION}${${_T}_VERSION_FULLSUFFIX}")
|
||||
set(_${_T}_VERSION_WB "${${_T}_VERSION}-${${_T}_VERSION_BUILD}")
|
||||
if (_out)
|
||||
set(_${_T}_VERSION_CHANGED 0)
|
||||
if ((NOT _${_T}_CACHED_VERSION) OR (NOT ("x${_${_T}_CACHED_VERSION}" STREQUAL "x${_${_T}_VERSION_WB}")))
|
||||
set(_${_T}_CACHED_VERSION "${_${_T}_VERSION_WB}" CACHE STRING "" FORCE)
|
||||
set(_${_T}_VERSION_CHANGED 1)
|
||||
endif()
|
||||
if ((NOT _${_T}_CACHED_VERSION_VER) OR (NOT ("x${_${_T}_CACHED_VERSION_VER}" STREQUAL "x${_VERSION_}")))
|
||||
set(_${_T}_CACHED_VERSION_VER "${_VERSION_}" CACHE STRING "" FORCE)
|
||||
set(_${_T}_VERSION_CHANGED 1)
|
||||
endif()
|
||||
if ((NOT EXISTS "${_out}") OR _${_T}_VERSION_CHANGED)
|
||||
get_filename_component(_def "${_out}" NAME)
|
||||
string(MAKE_C_IDENTIFIER "${_T}_${_def}" _def)
|
||||
string(TOUPPER "${_def}" _def)
|
||||
string(TOUPPER "${_T}" _TN)
|
||||
string(TIMESTAMP _cur_date "%d.%m.%Y %H:%M")
|
||||
file(WRITE "${_out}"
|
||||
"// This file generated by CMake set_version() version ${_VERSION_}
|
||||
|
||||
#ifndef ${_def}
|
||||
#define ${_def}
|
||||
|
||||
|
||||
// Project
|
||||
|
||||
#define ${_TN}_VERSION_MAJOR ${${_T}_VERSION_MAJOR}
|
||||
#define ${_TN}_VERSION_MINOR ${${_T}_VERSION_MINOR}
|
||||
#define ${_TN}_VERSION_REVISION ${${_T}_VERSION_REVISION}
|
||||
#define ${_TN}_VERSION_BUILD ${${_T}_VERSION_BUILD}
|
||||
#define ${_TN}_VERSION_SUFFIX \"${${_T}_VERSION_SUFFIX}\"
|
||||
#define ${_TN}_VERSION_NAME \"${${_T}_VERSION}\"
|
||||
#define ${_TN}_MAKE_VERSION(major, minor, revision) ((major << 16) | (minor << 8) | revision)
|
||||
#define ${_TN}_VERSION ${_TN}_MAKE_VERSION(${_TN}_VERSION_MAJOR, ${_TN}_VERSION_MINOR, ${_TN}_VERSION_REVISION)
|
||||
|
||||
|
||||
// Tools
|
||||
|
||||
#define ${_TN}_CMAKE_VERSION \"${CMAKE_VERSION}\"
|
||||
#define ${_TN}_CXX_COMPILER \"${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}\"
|
||||
#define ${_TN}_BUILD_DATE \"${_cur_date}\"
|
||||
#define ${_TN}_ARCH \"${MY_ARCH}\"
|
||||
|
||||
|
||||
#endif // ${_def}
|
||||
")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(set_lang _T)
|
||||
set(${_T}_LANG)
|
||||
foreach(_i ${ARGN})
|
||||
list(APPEND ${_T}_LANG "${_i}")
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(import_version _T _F)
|
||||
set(_names "${__version_names};FULLSUFFIX")
|
||||
foreach(_i ${_names})
|
||||
set(${_T}_VERSION_${_i} "${${_F}_VERSION_${_i}}")
|
||||
endforeach()
|
||||
set(${_T}_VERSION "${${_F}_VERSION}")
|
||||
set(${_T}_LANG "${${_F}_LANG}")
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(import_deploy_properties _T _F)
|
||||
foreach(_i ${__prop_names})
|
||||
set(${_T}_${_i} "${${_F}_${_i}}")
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(set_deploy_property _T)
|
||||
set(_name)
|
||||
set(_is_name 1)
|
||||
foreach(_i ${ARGN})
|
||||
if (("x${_i}" STREQUAL "xSHARED") OR ("x${_i}" STREQUAL "xSTATIC"))
|
||||
set(${_T}_TYPE "${_i}")
|
||||
elseif(_is_name)
|
||||
set(_is_name 0)
|
||||
if (_i IN_LIST __prop_names)
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid property name \"${_i}\"!")
|
||||
endif()
|
||||
set(_name ${_i})
|
||||
else()
|
||||
set(_is_name 1)
|
||||
set(${_T}_${_name} ${_i})
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(make_rc _T _out)
|
||||
if (WIN32)
|
||||
if ("x${${_T}_VERSION_MAJOR}" STREQUAL "x")
|
||||
message(FATAL_ERROR "Version for \"${_T}\" not set, use set_version()!")
|
||||
endif()
|
||||
string(REPLACE "\"" "\"\"" WINDOWS_RC_FULLNAME "${${_T}_FULLNAME}")
|
||||
string(REPLACE "\"" "\"\"" WINDOWS_RC_VERSION "${${_T}_VERSION}" )
|
||||
string(REPLACE "\"" "\"\"" WINDOWS_RC_LABEL "${${_T}_LABEL}" )
|
||||
string(REPLACE "\"" "\"\"" WINDOWS_RC_COMPANY "${${_T}_COMPANY}" )
|
||||
string(REPLACE "\"" "\"\"" WINDOWS_RC_INFO "${${_T}_INFO}" )
|
||||
if (("x${${_T}_TYPE}" STREQUAL "x") OR ("x${${_T}_TYPE}" STREQUAL "xEXECUTABLE"))
|
||||
set(WINDOWS_RC_FILETYPE "0x1L")
|
||||
set(_rc_prefix "")
|
||||
set(_rc_ext "exe")
|
||||
elseif ("x${${_T}_TYPE}" STREQUAL "xSHARED")
|
||||
set(WINDOWS_RC_FILETYPE "0x2L")
|
||||
set(_rc_prefix "lib")
|
||||
set(_rc_ext "dll")
|
||||
elseif ("x${${_T}_TYPE}" STREQUAL "xSTATIC")
|
||||
set(WINDOWS_RC_FILETYPE "0x7L")
|
||||
set(_rc_prefix "lib")
|
||||
set(_rc_ext "a")
|
||||
endif()
|
||||
set(_rc_version "${${_T}_VERSION_MAJOR},${${_T}_VERSION_MINOR},${${_T}_VERSION_REVISION},${${_T}_VERSION_BUILD}")
|
||||
set(_icon)
|
||||
if (NOT ("x${${_T}_ICON}" STREQUAL "x"))
|
||||
get_filename_component(WINDOWS_RC_ICON "${${_T}_ICON}" REALPATH BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(_icon "1 ICON \"${WINDOWS_RC_ICON}\"")
|
||||
endif()
|
||||
set(_rc_file "${CMAKE_CURRENT_BINARY_DIR}/${_T}_winres.rc")
|
||||
file(WRITE "${_rc_file}"
|
||||
"# if defined(UNDER_CE)
|
||||
# include <winbase.h>
|
||||
# else
|
||||
# include <winver.h>
|
||||
# endif
|
||||
#pragma code_page(65001)
|
||||
${_icon}
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION ${_rc_version}
|
||||
PRODUCTVERSION ${_rc_version}
|
||||
FILEFLAGSMASK 0x3fL
|
||||
FILEFLAGS 0x0L
|
||||
FILEOS 0x40004L
|
||||
FILETYPE ${WINDOWS_RC_FILETYPE}
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK \"StringFileInfo\"
|
||||
BEGIN
|
||||
BLOCK \"041904B0\"
|
||||
BEGIN
|
||||
VALUE \"Comments\", \"\\0\"
|
||||
VALUE \"CompanyName\", \"${WINDOWS_RC_COMPANY}\\0\"
|
||||
VALUE \"FileDescription\", \"${WINDOWS_RC_INFO}\\0\"
|
||||
VALUE \"FileVersion\", \"${WINDOWS_RC_VERSION}\\0\"
|
||||
VALUE \"InternalName\", \"${WINDOWS_RC_FULLNAME}\\0\"
|
||||
VALUE \"LegalTrademarks\", \"\\0\"
|
||||
VALUE \"LegalCopyright\", \"${WINDOWS_RC_COMPANY}\\0\"
|
||||
VALUE \"OriginalFilename\", \"${_rc_prefix}${_T}.${_rc_ext}\\0\"
|
||||
VALUE \"ProductName\", \"${WINDOWS_RC_LABEL}\\0\"
|
||||
VALUE \"ProductVersion\", \"${WINDOWS_RC_VERSION}\\0\"
|
||||
END
|
||||
END
|
||||
BLOCK \"VarFileInfo\"
|
||||
BEGIN
|
||||
VALUE \"Translation\", 0x0419, 0x04B0, 0x0409, 0x04B0
|
||||
END
|
||||
END
|
||||
")
|
||||
set(${_out} ${_rc_file})
|
||||
else()
|
||||
set(${_out})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
# Help macros begin
|
||||
|
||||
macro(__add_file_or_dir _DIR_VAR _FILE_VAR _PATH _RELPATH)
|
||||
set(_p)
|
||||
set(_abs 0)
|
||||
if (IS_ABSOLUTE "${_PATH}")
|
||||
set(_abs 1)
|
||||
endif()
|
||||
if ("${_PATH}" MATCHES "^\$<")
|
||||
set(_abs 1)
|
||||
endif()
|
||||
if (_abs)
|
||||
set(_p "${_PATH}")
|
||||
else()
|
||||
set(_p "${_RELPATH}/${_PATH}")
|
||||
endif()
|
||||
if ("${_p}" MATCHES ".*/$")
|
||||
string(LENGTH "${_p}" __sl)
|
||||
math(EXPR __sl ${__sl}-1)
|
||||
string(SUBSTRING "${_p}" 0 ${__sl} _p)
|
||||
list(APPEND ${_DIR_VAR} "${_p}")
|
||||
else()
|
||||
list(APPEND ${_FILE_VAR} "${_p}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
set(__win_host 0)
|
||||
set(__mac_host 0)
|
||||
if ("x${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "xWindows")
|
||||
set(__win_host 1)
|
||||
endif()
|
||||
if ("x${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "xDarwin")
|
||||
set(__mac_host 1)
|
||||
endif()
|
||||
|
||||
macro(__make_win_path _in_path _out_var _is_dir _out_dir)
|
||||
set(_add "")
|
||||
if (${_is_dir})
|
||||
set(_add "/")
|
||||
endif()
|
||||
file(TO_NATIVE_PATH "${_in_path}" ${_out_var})
|
||||
string(REPLACE "//" "/" ${_out_var} "${${_out_var}}${_add}")
|
||||
if (NOT "x${_out_dir}" STREQUAL "x")
|
||||
string(LENGTH "${${_out_var}}" __sl)
|
||||
math(EXPR __sl ${__sl}-1)
|
||||
string(SUBSTRING "${${_out_var}}" 0 ${__sl} __substr)
|
||||
get_filename_component(${_out_dir} "${__substr}" NAME)
|
||||
#message("dirname src=\"${${_out_var}}\", len=${__sl} \"${__substr}\" = \"${${_out_dir}}\"")
|
||||
endif()
|
||||
string(REPLACE "/" "\\" ${_out_var} "${${_out_var}}")
|
||||
endmacro()
|
||||
|
||||
macro(__make_dir _cmd _dest)
|
||||
if (__win_host)
|
||||
__make_win_path("${_dest}" __d 1 "")
|
||||
set(${_cmd} ${${_cmd}} COMMAND if not exist "\"${__d}\"" mkdir "\"${__d}\"")
|
||||
else()
|
||||
set(${_cmd} ${${_cmd}} COMMAND mkdir ${_VERB} -p "${_dest}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(__make_copy _cmd _dirs _files _dest)
|
||||
if (${_dirs} OR ${_files})
|
||||
__make_dir(${_cmd} "${_dest}")
|
||||
endif()
|
||||
if (__win_host)
|
||||
__make_win_path("${_dest}" _wdest 1 "")
|
||||
foreach(_d ${${_dirs}})
|
||||
__make_win_path("${_d}" _wsrc 1 _dirname)
|
||||
__make_dir(${_cmd} "${_dest}/${_dirname}")
|
||||
set(${_cmd} ${${_cmd}} COMMAND xcopy /y /r /e "${_wsrc}*" "\"${_wdest}${_dirname}\\\"" ${_WVERB})
|
||||
endforeach()
|
||||
foreach(_f ${${_files}})
|
||||
__make_win_path("${_f}" _wsrc 0 "")
|
||||
set(${_cmd} ${${_cmd}} COMMAND xcopy /y /r "\"${_wsrc}\"" "\"${_wdest}\"" ${_WVERB})
|
||||
endforeach()
|
||||
else()
|
||||
foreach(_d ${${_dirs}})
|
||||
set(${_cmd} ${${_cmd}} COMMAND cp ${_VERB} -rf "${_d}" "${_dest}/")
|
||||
endforeach()
|
||||
foreach(_f ${${_files}})
|
||||
set(${_cmd} ${${_cmd}} COMMAND cp ${_VERB} -f "${_f}" "${_dest}/")
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(__gather_deps _T _search_path_var _dep_libs_var _dep_libs_cs_var _added_)
|
||||
get_target_property(_LL${_T} ${_T} LINK_LIBRARIES)
|
||||
foreach (_L${_T} ${_LL${_T}})
|
||||
if (TARGET ${_L${_T}})
|
||||
get_target_property(_II${_T} ${_L${_T}} IMPORTED)
|
||||
if (NOT _II${_T})
|
||||
#message("depend on ${_L${_T}}")
|
||||
get_target_property(_LT${_T} ${_L${_T}} TYPE)
|
||||
if (("x${_LT${_T}}" STREQUAL "xSHARED_LIBRARY") OR ("x${_LT${_T}}" STREQUAL "xSTATIC_LIBRARY"))
|
||||
if (NOT _L${_T} IN_LIST ${_added_})
|
||||
list(APPEND ${_added_} ${_L${_T}})
|
||||
__gather_deps(${_L${_T}} ${_search_path_var} ${_dep_libs_var} ${_dep_libs_cs_var} ${_added_})
|
||||
if ("x${_LT${_T}}" STREQUAL "xSHARED_LIBRARY")
|
||||
if (NOT DEFINED ANDROID_PLATFORM)
|
||||
set(${_search_path_var} "${${_search_path_var}}${_dt_delim}$<TARGET_FILE_DIR:${_L${_T}}>")
|
||||
endif()
|
||||
set(${_dep_libs_cs_var} "${${_dep_libs_cs_var}}${_dt_delim}$<TARGET_FILE_DIR:${_L${_T}}>/$<TARGET_FILE_NAME:${_L${_T}}>")
|
||||
set(${_dep_libs_var} "${${_dep_libs_var}}" "$<TARGET_FILE_DIR:${_L${_T}}>/$<TARGET_FILE_NAME:${_L${_T}}>")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
set(__macos_privacy_text "Application request permission")
|
||||
set(__macos_privacies
|
||||
"<key>NFCReaderUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>
|
||||
<key>NSAppleMusicUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>
|
||||
<key>NSBluetoothPeripheralUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>
|
||||
<key>NSCalendarsUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>
|
||||
<key>NSContactsUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>
|
||||
<key>NSFaceIDUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>
|
||||
<key>NSHealthShareUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>
|
||||
<key>NSHealthUpdateUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>
|
||||
<key>NSHomeKitUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>
|
||||
<key>NSLocationAlwaysUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>
|
||||
<key>NSLocationWhenInUseUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>
|
||||
<key>NSMotionUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>
|
||||
<key>NSPhotoLibraryAddUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>
|
||||
<key>NSPhotoLibraryUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>
|
||||
<key>NSRemindersUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>
|
||||
<key>NSVideoSubscriberAccountUsageDescription</key>
|
||||
<string>${__macos_privacy_text}</string>"
|
||||
)
|
||||
set(__gradle_lang_start
|
||||
" defaultConfig {
|
||||
resConfigs ")
|
||||
set(__gradle_sign
|
||||
" signingConfigs {
|
||||
debug {
|
||||
storeFile file(DEBUG_STORE_FILE)
|
||||
}
|
||||
release {
|
||||
storeFile file(RELEASE_STORE_FILE)
|
||||
storePassword RELEASE_STORE_PASSWORD
|
||||
keyPassword RELEASE_KEY_PASSWORD
|
||||
keyAlias RELEASE_KEY_ALIAS
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
release {
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}")
|
||||
|
||||
# Help macros end
|
||||
|
||||
|
||||
macro(deploy_target _T)
|
||||
set(_DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
||||
set(_DEPLOY_DIR "${CMAKE_INSTALL_PREFIX}")
|
||||
set(_RES_DIRS)
|
||||
set(_RES_FILES)
|
||||
set(_PLUG_DIRS)
|
||||
set(_PLUG_FILES)
|
||||
set(_FILE_DIRS)
|
||||
set(_FILE_FILES)
|
||||
set(_LIBS_DIRS)
|
||||
set(_LIBS_FILES)
|
||||
set(_VERB)
|
||||
set(_WVERB 1> NUL)
|
||||
set(_OPTIONS)
|
||||
set(_ZIP_DMG 1)
|
||||
set(_DEB_OPT 1)
|
||||
set(_DEB_SERVICE 0)
|
||||
set(_cur_arg)
|
||||
set(__args "DESTINATION;DEPLOY_DIR;RESOURCES;PLUGINS;FILES;LIBS;OPTIONS;VERBOSE;DMG_NO_ZIP;DEB_USR_DIR;DEB_ADD_SERVICE")
|
||||
foreach(_i ${ARGN})
|
||||
if (_i IN_LIST __args)
|
||||
set(_cur_arg "${_i}")
|
||||
if ("${_cur_arg}" STREQUAL "VERBOSE")
|
||||
set(_VERB -v)
|
||||
set(_WVERB)
|
||||
elseif("${_cur_arg}" STREQUAL "DMG_NO_ZIP")
|
||||
set(_ZIP_DMG 0)
|
||||
elseif("${_cur_arg}" STREQUAL "DEB_USR_DIR")
|
||||
set(_DEB_OPT 0)
|
||||
elseif("${_cur_arg}" STREQUAL "DEB_ADD_SERVICE")
|
||||
set(_DEB_SERVICE 1)
|
||||
endif()
|
||||
elseif ("${_cur_arg}" STREQUAL "DESTINATION")
|
||||
set(_cur_arg)
|
||||
set(_DESTINATION "${_i}/")
|
||||
elseif ("${_cur_arg}" STREQUAL "DEPLOY_DIR")
|
||||
set(_cur_arg)
|
||||
set(_DEPLOY_DIR "${_i}/")
|
||||
elseif ("${_cur_arg}" STREQUAL "RESOURCES")
|
||||
__add_file_or_dir(_RES_DIRS _RES_FILES "${_i}" "${_DEPLOY_DIR}")
|
||||
elseif ("${_cur_arg}" STREQUAL "PLUGINS")
|
||||
__add_file_or_dir(_PLUG_DIRS _PLUG_FILES "${_i}" "${_DEPLOY_DIR}")
|
||||
elseif ("${_cur_arg}" STREQUAL "FILES")
|
||||
__add_file_or_dir(_FILE_DIRS _FILE_FILES "${_i}" "${_DEPLOY_DIR}")
|
||||
elseif ("${_cur_arg}" STREQUAL "LIBS")
|
||||
__add_file_or_dir(_LIBS_DIRS _LIBS_FILES "${_i}" "${_DEPLOY_DIR}")
|
||||
elseif ("${_cur_arg}" STREQUAL "OPTIONS")
|
||||
list(APPEND _OPTIONS "${_i}")
|
||||
endif()
|
||||
#message("-i = ${_i}")
|
||||
endforeach()
|
||||
get_filename_component(_ICON_NAME "${${_T}_ICON}" NAME)
|
||||
get_filename_component(_ICON_FN "${${_T}_ICON}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(_TV "${_T}_${${_T}_VERSION}")
|
||||
set(_DEP_LIBPATH)
|
||||
set(_DEP_LIBS_CS)
|
||||
set(_DEP_LIBS)
|
||||
set(_add_search_path)
|
||||
set(_added_)
|
||||
set(_ADD_DEPS ${_PLUG_DIRS} ${_PLUG_FILES} ${_FILE_DIRS} ${_FILE_FILES} ${_LIBS_DIRS} ${_LIBS_FILES})
|
||||
__gather_deps(${_T} _add_search_path _DEP_LIBS _DEP_LIBS_CS _added_)
|
||||
foreach (_L ${DEPLOY_ADD_LIBPATH})
|
||||
set(_add_search_path "${_add_search_path}${_dt_delim}${_L}")
|
||||
endforeach()
|
||||
#message("app depend ${_T} libpath ${_add_search_path}")
|
||||
set(_CMD_)
|
||||
set(_deployed)
|
||||
if ("x${CMAKE_SYSTEM_NAME}" STREQUAL "xLinux")
|
||||
set(_os_id "")
|
||||
set(_os_ver "")
|
||||
set(_paths "/usr/lib" "/etc")
|
||||
if (CMAKE_CROSSCOMPILING)
|
||||
set(_paths "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/../etc")
|
||||
endif()
|
||||
find_file(_release_file NAMES os-release lsb-release PATHS ${_paths} NO_DEFAULT_PATH)
|
||||
if (NOT "x${_release_file}" STREQUAL "x")
|
||||
file(STRINGS "${_release_file}" _lines)
|
||||
foreach(_l ${_lines})
|
||||
if ("${_l}" MATCHES "VERSION_ID=.*")
|
||||
string(SUBSTRING "${_l}" 11 -1 _os_ver)
|
||||
string(REPLACE "\"" "" _os_ver "${_os_ver}")
|
||||
#message("VERSION_ID ${_os_ver}")
|
||||
elseif ("${_l}" MATCHES "ID=.*")
|
||||
string(SUBSTRING "${_l}" 3 -1 _os_id)
|
||||
string(REPLACE "\"" "" _os_id "${_os_id}")
|
||||
#message("ID ${_os_id}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
set(_build "${${_T}_VERSION_BUILD}")
|
||||
if (NOT "x${_build}" STREQUAL "x")
|
||||
set(_build "-${_build}")
|
||||
endif()
|
||||
string(TOLOWER "${_os_id}${_os_ver}" _TARGET_OS)
|
||||
if ("x${_TARGET_OS}" STREQUAL "x")
|
||||
set(_TARGET_OS "linux")
|
||||
endif()
|
||||
string(REPLACE "_" "-" _DEBNAME "${_T}")
|
||||
set(_DEBVERSION "${${_T}_VERSION_MAJOR}.${${_T}_VERSION_MINOR}.${${_T}_VERSION_REVISION}${_build}${${_T}_VERSION_FULLSUFFIX}+${_TARGET_OS}")
|
||||
string(REPLACE "_" "-" _DEBVERSION "${_DEBVERSION}")
|
||||
string(TOLOWER "${_DEBNAME}" _DEBNAME)
|
||||
set(_DEB_ARCH)
|
||||
if("_${MY_ARCH}" STREQUAL "_arm64")
|
||||
set(_DEB_ARCH "arm64")
|
||||
elseif("_${MY_ARCH}" STREQUAL "_armv7")
|
||||
set(_DEB_ARCH "armhf")
|
||||
elseif("_${MY_ARCH}" STREQUAL "_i386")
|
||||
set(_DEB_ARCH "i386")
|
||||
elseif("_${MY_ARCH}" STREQUAL "_x86_64")
|
||||
set(_DEB_ARCH "amd64")
|
||||
elseif("_${MY_ARCH}" STREQUAL "_ppc")
|
||||
set(_DEB_ARCH "PowerPC")
|
||||
elseif("_${MY_ARCH}" STREQUAL "_ppc64")
|
||||
set(_DEB_ARCH "PPC64")
|
||||
elseif("_${MY_ARCH}" STREQUAL "_ia64")
|
||||
set(_DEB_ARCH "ia64")
|
||||
endif()
|
||||
set(_DEB "${_TV}_deb_${_DEB_ARCH}")
|
||||
set(_AGD "${_DEPLOY_DIR}/${_DEB}")
|
||||
set(_C_echof ">" "${_AGD}/DEBIAN/control")
|
||||
set(_C_echo ">>" "${_AGD}/DEBIAN/control")
|
||||
set(_D_echof ">" "${_AGD}/usr/share/applications/${_DEBNAME}.desktop")
|
||||
set(_D_echo ">>" "${_AGD}/usr/share/applications/${_DEBNAME}.desktop")
|
||||
set(_bin_path "${_AGD}/usr/bin")
|
||||
set(_lib_path "${_AGD}/usr/lib")
|
||||
set(_pli_path "${_AGD}/usr/lib/${${_T}_COMPANY}/${_T}")
|
||||
set(_res_path "${_AGD}/usr/share/${${_T}_COMPANY}/${_T}")
|
||||
set(_ico_path "${_AGD}/usr/share/pixmaps")
|
||||
set(_app_bin_path "/usr/bin")
|
||||
set(_app_ico_path "/usr/share/pixmaps")
|
||||
if(_DEB_OPT)
|
||||
set(_bin_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}")
|
||||
set(_lib_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}/lib")
|
||||
set(_pli_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}")
|
||||
set(_res_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}")
|
||||
set(_ico_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}/pixmaps")
|
||||
set(_app_bin_path "/opt/${${_T}_COMPANY}/${_T}")
|
||||
set(_app_ico_path "/opt/${${_T}_COMPANY}/${_T}/pixmaps")
|
||||
endif()
|
||||
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_bin_path}")
|
||||
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_lib_path}")
|
||||
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_pli_path}")
|
||||
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_res_path}")
|
||||
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_ico_path}")
|
||||
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_AGD}/usr/share/applications")
|
||||
__make_copy(_CMD_ _FILE_DIRS _FILE_FILES ${_bin_path})
|
||||
__make_copy(_CMD_ _PLUG_DIRS _PLUG_FILES ${_pli_path})
|
||||
__make_copy(_CMD_ _RES_DIRS _RES_FILES ${_res_path})
|
||||
__make_copy(_CMD_ _LIBS_DIRS _LIBS_FILES ${_lib_path})
|
||||
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_DEPLOY_DIR}/${_T}" "${_bin_path}/")
|
||||
if (_DEP_LIBS)
|
||||
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_DEP_LIBS}" "${_lib_path}/")
|
||||
endif()
|
||||
if (_ICON_NAME)
|
||||
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_ICON_FN}" "${_ico_path}/")
|
||||
endif()
|
||||
if(_DEB_OPT)
|
||||
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_AGD}/usr/bin")
|
||||
set(_CMD_ ${_CMD_} COMMAND ln -srf ${_VERB} "${_bin_path}/${_T}" "${_AGD}/usr/bin/${_T}")
|
||||
endif()
|
||||
|
||||
file(GLOB _files "${CMAKE_CURRENT_SOURCE_DIR}/debian/DEBIAN/*")
|
||||
foreach (_f ${_files})
|
||||
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_f}" "${_AGD}/DEBIAN/")
|
||||
endforeach()
|
||||
|
||||
file(GLOB _files "${_AGD}/DEBIAN/p*inst" "${_AGD}/DEBIAN/p*rm" "${_AGD}/DEBIAN/config")
|
||||
foreach (_f ${_files})
|
||||
set(_CMD_ ${_CMD_} COMMAND chmod 0755 ${_VERB} "${_f}")
|
||||
endforeach()
|
||||
|
||||
if (NOT CMAKE_LDD)
|
||||
find_program(CMAKE_LDD ldd)
|
||||
endif()
|
||||
set(_dt_opts -l "${CMAKE_LDD}")
|
||||
if (CMAKE_CROSSCOMPILING)
|
||||
set(_dt_searchdirs "${CMAKE_PREFIX_PATH}/lib")
|
||||
if (NOT "x${CMAKE_LIBRARY_ARCHITECTURE}" STREQUAL "x")
|
||||
set(_dt_searchdirs "${_dt_searchdirs}${_dt_delim}${CMAKE_PREFIX_PATH}/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
|
||||
set(_dt_searchdirs "${_dt_searchdirs}${_dt_delim}${CMAKE_PREFIX_PATH}/../lib/${CMAKE_LIBRARY_ARCHITECTURE}")
|
||||
endif()
|
||||
set(_dt_opts -L "${CMAKE_READELF}" --dpkg-workdir "${CMAKE_DPKG_WORKDIR}" -s "${_dt_searchdirs}")
|
||||
endif()
|
||||
set(_deb_name "${_TV}_${_TARGET_OS}_${_DEB_ARCH}.deb")
|
||||
#message("VER = \"${_DEBVERSION}\"")
|
||||
#message("DEB = \"${_deb_name}\"")
|
||||
list(APPEND _CMD_ COMMAND echo "Package: ${_DEBNAME}" ${_C_echof})
|
||||
list(APPEND _CMD_ COMMAND echo "Version: ${_DEBVERSION}" ${_C_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Architecture: ${_DEB_ARCH}" ${_C_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Maintainer: ${${_T}_COMPANY} <>" ${_C_echo})
|
||||
list(APPEND _CMD_ COMMAND ${PIP_DEPLOY_TOOL} ${_OPTIONS} --prefix "Depends: " --dependencies ${_dt_opts} -a "${_DEP_LIBS_CS}" -o "${_lib_path}" ${_DEPLOY_DIR}/${_T} ${_ADD_DEPS} ${_C_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Conflicts:" ${_C_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Replaces:" ${_C_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Section: misc" ${_C_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Priority: optional" ${_C_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Description: ${${_T}_INFO}" ${_C_echo})
|
||||
|
||||
list(APPEND _CMD_ COMMAND echo "[Desktop Entry]" ${_D_echof})
|
||||
list(APPEND _CMD_ COMMAND echo "Encoding=UTF-8" ${_D_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Type=Application" ${_D_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Name=${${_T}_LABEL}" ${_D_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "GenericName=${${_T}_LABEL}" ${_D_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Comment=${${_T}_INFO}" ${_D_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Exec=${_app_bin_path}/${_T}" ${_D_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Icon=${_app_ico_path}/${_ICON_NAME}" ${_D_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Terminal=false" ${_D_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "StartupNotify=true" ${_D_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Categories=Utility;" ${_D_echo})
|
||||
|
||||
add_custom_target(deploy_${_T}
|
||||
# gather deb dir
|
||||
COMMAND rm -rf ${_VERB} "${_AGD}"
|
||||
COMMAND mkdir ${_VERB} -p "${_AGD}/DEBIAN"
|
||||
${_CMD_}
|
||||
|
||||
# generate deb
|
||||
COMMAND cd ${_AGD} "&&" md5deep -rl opt usr ">" DEBIAN/md5sums
|
||||
COMMAND mkdir ${_VERB} -p ${_DESTINATION}
|
||||
COMMAND dpkg-deb -Z gzip -b ${_AGD} ${_DESTINATION}/${_deb_name}
|
||||
VERBATIM
|
||||
COMMENT "Generating ${_deb_name}"
|
||||
)
|
||||
set(_deployed "deploy_${_T}")
|
||||
|
||||
if (_DEB_SERVICE)
|
||||
set(_CMD_)
|
||||
set(_DEB "${_TV}-service_deb_${_DEB_ARCH}")
|
||||
set(_AGD "${_DEPLOY_DIR}/${_DEB}")
|
||||
set(_C_echof ">" "${_AGD}/DEBIAN/control")
|
||||
set(_C_echo ">>" "${_AGD}/DEBIAN/control")
|
||||
set(_opt_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}")
|
||||
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_opt_path}")
|
||||
|
||||
file(GLOB _files "${CMAKE_CURRENT_SOURCE_DIR}/debian-service/*.service")
|
||||
foreach (_f ${_files})
|
||||
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_f}" "${_opt_path}/")
|
||||
endforeach()
|
||||
|
||||
set(__deb_dir "${CMAKE_CURRENT_SOURCE_DIR}/debian-service/DEBIAN")
|
||||
file(GLOB _files "${__deb_dir}/*")
|
||||
foreach (_f ${_files})
|
||||
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_f}" "${_AGD}/DEBIAN/")
|
||||
endforeach()
|
||||
|
||||
file(GLOB _files RELATIVE "${__deb_dir}" "${__deb_dir}/p*inst" "${__deb_dir}/p*rm" "${__deb_dir}/config")
|
||||
foreach (_f ${_files})
|
||||
set(_CMD_ ${_CMD_} COMMAND chmod 0755 ${_VERB} "${_AGD}/DEBIAN/${_f}")
|
||||
endforeach()
|
||||
|
||||
set(_deb_name "${_TV}-service_${_TARGET_OS}_${_DEB_ARCH}.deb")
|
||||
#message("VER = \"${_DEBVERSION}\"")
|
||||
#message("DEB = \"${_deb_name}\"")
|
||||
list(APPEND _CMD_ COMMAND echo "Package: ${_DEBNAME}-service" ${_C_echof})
|
||||
list(APPEND _CMD_ COMMAND echo "Version: ${_DEBVERSION}" ${_C_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Architecture: ${_DEB_ARCH}" ${_C_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Maintainer: ${${_T}_COMPANY} <>" ${_C_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Depends: ${_DEBNAME} (>= ${_DEBVERSION})" ${_C_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Conflicts:" ${_C_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Replaces:" ${_C_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Section: misc" ${_C_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Priority: optional" ${_C_echo})
|
||||
list(APPEND _CMD_ COMMAND echo "Description: ${${_T}_LABEL} service" ${_C_echo})
|
||||
|
||||
add_custom_target(deploy_${_T}-service
|
||||
# gather deb dir
|
||||
COMMAND rm -rf ${_VERB} "${_AGD}"
|
||||
COMMAND mkdir ${_VERB} -p "${_AGD}/DEBIAN"
|
||||
${_CMD_}
|
||||
|
||||
# generate deb
|
||||
COMMAND mkdir ${_VERB} -p ${_DESTINATION}
|
||||
COMMAND dpkg-deb -Z gzip -b ${_AGD} ${_DESTINATION}/${_deb_name}
|
||||
VERBATIM
|
||||
COMMENT "Generating ${_deb_name}"
|
||||
)
|
||||
list(APPEND _deployed "deploy_${_T}-service")
|
||||
endif()
|
||||
|
||||
elseif(WIN32)
|
||||
if (NOT CMAKE_OBJDUMP)
|
||||
find_program(CMAKE_OBJDUMP objdump)
|
||||
endif()
|
||||
set(_AGD "${_DEPLOY_DIR}/${_TV}_win_${MY_ARCH}/")
|
||||
if (__win_host)
|
||||
string(REPLACE "/" "\\" CMAKE_OBJDUMP "${CMAKE_OBJDUMP}")
|
||||
endif()
|
||||
set(_var_exe "${_DEPLOY_DIR}/${_T}.exe")
|
||||
set(_var_empty)
|
||||
__make_dir(_CMD_ "${_AGD}")
|
||||
__make_dir(_CMD_ "${_DESTINATION}")
|
||||
__make_copy(_CMD_ _var_empty _var_exe "${_AGD}")
|
||||
__make_copy(_CMD_ _RES_DIRS _RES_FILES "${_AGD}")
|
||||
__make_copy(_CMD_ _PLUG_DIRS _PLUG_FILES "${_AGD}")
|
||||
__make_copy(_CMD_ _FILE_DIRS _FILE_FILES "${_AGD}")
|
||||
__make_copy(_CMD_ _LIBS_DIRS _LIBS_FILES "${_AGD}")
|
||||
set(_zip_name "${_TV}_windows_${MY_ARCH}.zip")
|
||||
add_custom_target(deploy_${_T}
|
||||
# gather dir
|
||||
${_CMD_}
|
||||
|
||||
COMMAND ${PIP_DEPLOY_TOOL} ${_VERB} ${_OPTIONS} -W "\"${CMAKE_OBJDUMP}\"" -P windows,minimal -S windows -q "\"${Qt5_ROOT}\"" -s "\"${CMAKE_PREFIX_PATH}/bin${_dt_delim}${MINGW_BIN}${_add_search_path}\"" -o ${_AGD} -p ${_AGD} "\"${_AGD}${_T}.exe\"" ${_ADD_DEPS}
|
||||
# zip
|
||||
COMMAND cd "\"${_DEPLOY_DIR}\"" "&&" zip -q -r "\"${_DESTINATION}/${_zip_name}\"" "\"${_TV}_win_${MY_ARCH}\""
|
||||
COMMENT "Generating ${_zip_name}"
|
||||
)
|
||||
set(_deployed "deploy_${_T}")
|
||||
elseif (APPLE)
|
||||
set(MACOSX_BUNDLE_GUI_IDENTIFIER "${${_T}_FULLNAME}")
|
||||
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${${_T}_VERSION}")
|
||||
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${${_T}_VERSION}")
|
||||
set(MACOSX_BUNDLE_ICON_FILE "${_ICON_NAME}")
|
||||
set(MACOSX_BUNDLE_BUNDLE_NAME "${${_T}_LABEL}")
|
||||
set(MACOSX_BUNDLE_COPYRIGHT "${${_T}_COMPANY}")
|
||||
set(MACOSX_BUNDLE_INFO_STRING "${${_T}_INFO}")
|
||||
set(MACOSX_BUNDLE_BUNDLE_VERSION "6.0")
|
||||
set(MACOSX_BUNDLE_SIGNATURE "????")
|
||||
set(MACOSX_BUNDLE_PRIVACIES "${__macos_privacies}")
|
||||
set_target_properties(${_T} PROPERTIES MACOSX_BUNDLE TRUE)
|
||||
set_target_properties(${_T} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${_modules_dir}/PIMacOSBundle.plist.in")
|
||||
set(_AGD "${_DEPLOY_DIR}/${_T}.app")
|
||||
set(_DMG "${CMAKE_CURRENT_BINARY_DIR}/dmg")
|
||||
__make_copy(_CMD_ _RES_DIRS _RES_FILES "${_AGD}/Contents/Resources")
|
||||
__make_copy(_CMD_ _PLUG_DIRS _PLUG_FILES "${_AGD}/Contents/PlugIns")
|
||||
__make_copy(_CMD_ _FILE_DIRS _FILE_FILES "${_AGD}/Contents/MacOS")
|
||||
__make_copy(_CMD_ _LIBS_DIRS _LIBS_FILES "${_AGD}/Contents/Frameworks")
|
||||
if (_ICON_NAME)
|
||||
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f ${_ICON_FN} ${_AGD}/Contents/Resources)
|
||||
endif()
|
||||
if (NOT CMAKE_OTOOL)
|
||||
set(CMAKE_OTOOL "otool")
|
||||
endif()
|
||||
if (NOT CMAKE_PREFIX_PATH)
|
||||
set(CMAKE_PREFIX_PATH "/usr/local")
|
||||
endif()
|
||||
set(_dmg_name "${_TV}_macosx_x64.dmg")
|
||||
set(_cmd_gen_dmg COMMAND genisoimage -quiet -V "${MACOSX_BUNDLE_BUNDLE_NAME}" -D -R -apple -no-pad -o ${_DESTINATION}/${_dmg_name} ${_DMG})
|
||||
if (__mac_host)
|
||||
set(_cmd_gen_dmg COMMAND hdiutil create ${_DESTINATION}/${_dmg_name} -ov -volname "${MACOSX_BUNDLE_BUNDLE_NAME}" -fs HFS+ -srcfolder ${_DMG})
|
||||
endif()
|
||||
if (_ZIP_DMG)
|
||||
set(_cmd_gen_dmg ${_cmd_gen_dmg} COMMAND zip -q -r "\"${_DESTINATION}/${_dmg_name}.zip\"" "\"${_DESTINATION}/${_dmg_name}\"")
|
||||
set(_cmd_gen_dmg ${_cmd_gen_dmg} COMMAND rm "\"${_DESTINATION}/${_dmg_name}\"")
|
||||
endif()
|
||||
set(_comment "Generating ${_dmg_name}")
|
||||
if (_ZIP_DMG)
|
||||
set(_comment "${_comment}.zip")
|
||||
endif()
|
||||
add_custom_target(deploy_${_T}
|
||||
# gather .app dir
|
||||
COMMAND mkdir ${_VERB} -p ${_AGD}/Contents/Resources
|
||||
COMMAND mkdir ${_VERB} -p ${_AGD}/Contents/Frameworks
|
||||
COMMAND mkdir ${_VERB} -p ${_DESTINATION}
|
||||
${_CMD_}
|
||||
COMMAND ${PIP_DEPLOY_TOOL} ${_VERB} ${_OPTIONS} -M "${CMAKE_OTOOL}" -P cocoa,minimal -S mac -q ${Qt5_ROOT} -s "\"${CMAKE_PREFIX_PATH}/lib${_add_search_path}\"" -o ${_AGD}/Contents/Frameworks -p ${_AGD}/Contents/PlugIns ${_AGD}/Contents/MacOS/${_T} ${_ADD_DEPS}
|
||||
# prepare dmg dir
|
||||
COMMAND rm -rf ${_DMG}
|
||||
COMMAND mkdir ${_VERB} -p ${_DMG}
|
||||
COMMAND cp -r ${_AGD} ${_DMG}
|
||||
COMMAND ln ${_VERB} -s /Applications ${_DMG}
|
||||
# generate dmg
|
||||
${_cmd_gen_dmg}
|
||||
COMMENT "${_comment}"
|
||||
)
|
||||
set(_deployed "deploy_${_T}")
|
||||
elseif (DEFINED ANDROID_PLATFORM)
|
||||
set(_res_files)
|
||||
set(_res_files "${_res_files}\n <qresource prefix=\"/\">")
|
||||
foreach (_f ${_RES_FILES})
|
||||
set(_res_files "${_res_files}\n <file>${_f}</file>")
|
||||
endforeach()
|
||||
set(_res_files "${_res_files}\n </qresource>")
|
||||
foreach (_d ${_RES_DIRS})
|
||||
file(GLOB_RECURSE _df "${_d}/*")
|
||||
#message("FILES ${_d} = ${_df}")
|
||||
get_filename_component(_dn "${_d}" NAME)
|
||||
set(_res_files "${_res_files}\n <qresource prefix=\"${_dn}\">")
|
||||
foreach (_f ${_df})
|
||||
get_filename_component(_fn "${_f}" NAME)
|
||||
set(_res_files "${_res_files}\n <file alias=\"${_fn}\">${_f}</file>")
|
||||
endforeach()
|
||||
set(_res_files "${_res_files}\n </qresource>")
|
||||
endforeach()
|
||||
set(_res_qrc "${CMAKE_CURRENT_BINARY_DIR}/android_res.qrc")
|
||||
file(WRITE "${_res_qrc}" "<RCC>${_res_files}\n</RCC>")
|
||||
set(_AT ${_T}_lib)
|
||||
set(_ATA ${_AT}_${ANDROID_ABI})
|
||||
get_target_property(_sources ${_T} SOURCES)
|
||||
get_target_property(_libs ${_T} LINK_LIBRARIES)
|
||||
get_target_property(_incs ${_T} INCLUDE_DIRECTORIES)
|
||||
get_target_property(_defs ${_T} COMPILE_DEFINITIONS)
|
||||
qt5_add_resources(_res_out "${_res_qrc}")
|
||||
add_library(${_ATA} SHARED ${_sources} ${_res_out})
|
||||
target_link_libraries(${_ATA} ${_libs})
|
||||
target_include_directories(${_ATA} PRIVATE ${_incs})
|
||||
target_compile_definitions(${_ATA} PRIVATE ${_defs})
|
||||
set_target_properties(${_T} PROPERTIES EXCLUDE_FROM_ALL 1)
|
||||
#message("create new target ${_ATA} ${_sources} ${_libs}")
|
||||
set(_AGD "${_DEPLOY_DIR}/${_T}.android")
|
||||
__make_dir(_CMD_ "${_AGD}")
|
||||
set(_file)
|
||||
set(_dir "${CMAKE_BINARY_DIR}/android-build/libs" "${CMAKE_CURRENT_SOURCE_DIR}/android/res" "${CMAKE_CURRENT_SOURCE_DIR}/android/src")
|
||||
__make_copy(_CMD_ _dir _file "${_AGD}")
|
||||
set(_dir)
|
||||
set(_file "${Qt5_ROOT}/src/android/templates/res/values/libs.xml")
|
||||
__make_copy(_CMD_ _dir _file "${_AGD}/res/values")
|
||||
set(_dir "${Qt5_ROOT}/src/3rdparty/gradle/gradle")
|
||||
set(_file "${Qt5_ROOT}/src/3rdparty/gradle/gradlew"
|
||||
"${Qt5_ROOT}/src/3rdparty/gradle/gradlew.bat")
|
||||
__make_copy(_CMD_ _dir _file "${_AGD}")
|
||||
#message("bindir = ${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(SDK_ROOT "$ENV{ANDROID_SDK_ROOT}")
|
||||
if("x${SDK_ROOT}" STREQUAL "x")
|
||||
set(SDK_ROOT "$ENV{ANDROID_HOME}")
|
||||
endif()
|
||||
set(__archs "armeabi-v7a" "arm64-v8a" "x86" "x86_64")
|
||||
set(QT_ANDROID_ARCHITECTURES)
|
||||
find_library(_lib_ c++_shared)
|
||||
foreach (_a ${__archs})
|
||||
set(_aname "${_a}")
|
||||
if ("${_a}" STREQUAL "armeabi-v7a")
|
||||
set(_aname "arm")
|
||||
elseif ("${_a}" STREQUAL "arm64-v8a")
|
||||
set(_aname "arm64")
|
||||
endif()
|
||||
set(_exist 0)
|
||||
if ("${_a}" STREQUAL "${ANDROID_ABI}")
|
||||
set(_exist 1)
|
||||
elseif (EXISTS "${CMAKE_BINARY_DIR}/android-build/libs/${_a}")
|
||||
set(_exist 1)
|
||||
endif()
|
||||
if (_exist)
|
||||
string(REPLACE "${ANDROID_ABI}" "${_a}" _a_prefix "${CMAKE_PREFIX_PATH}")
|
||||
string(REPLACE "arch-${ANDROID_ARCH_NAME}" "arch-${_aname}" _a_prefix "${_a_prefix}")
|
||||
list(APPEND QT_ANDROID_ARCHITECTURES " \"${_a}\" : \"${ANDROID_SYSROOT_${_a}}\"")
|
||||
string(REPLACE "${ANDROID_SYSROOT_${ANDROID_ABI}}" "${ANDROID_SYSROOT_${_a}}" _lib_${_a} "${_lib_}")
|
||||
#message("search = ${_a_prefix}/lib")
|
||||
__make_copy(_CMD_ _empty _lib_${_a} "${_AGD}/libs/${_a}")
|
||||
set(_CMD_ ${_CMD_} COMMAND ${PIP_DEPLOY_TOOL} ${_VERB} ${_OPTIONS} -W "\"${CMAKE_OBJDUMP}\"" -s "${_a_prefix}/lib${_dt_delim}${Qt5_ROOT}/lib${_add_search_path}" -o "\"${_AGD}/libs/${_a}\"" --ignore "\"c${_dt_delim}m${_dt_delim}z${_dt_delim}dl${_dt_delim}log\"" "\"${_AGD}/libs/${_a}/lib${_AT}_${_a}.so\"" ${_ADD_DEPS})
|
||||
#message("c++_${_a} -> ${_lib_${_a}}")
|
||||
endif()
|
||||
endforeach()
|
||||
string(REPLACE ";" ",\n" QT_ANDROID_ARCHITECTURES "${QT_ANDROID_ARCHITECTURES}")
|
||||
set(QT_ANDROID_APPLICATION_BINARY ${_AT})
|
||||
set(ANDROID_LABEL "${${_T}_LABEL}")
|
||||
set(ANDROID_ICON "${${_T}_ICON}")
|
||||
set(ANDROID_VERSION "${${_T}_VERSION}")
|
||||
set(ANDROID_BUILD "${${_T}_VERSION_BUILD}")
|
||||
set(ANDROID_PACKAGE "${${_T}_FULLNAME}")
|
||||
set(ANDROID_TARGET_SDK "${${_T}_ANDROID_TARGET_SDK}")
|
||||
set(ANDROID_STORE_FILE "${${_T}_ANDROID_STORE_FILE}")
|
||||
set(ANDROID_STORE_PASSWORD "${${_T}_ANDROID_STORE_PASSWORD}")
|
||||
set(ANDROID_KEY_PASSWORD "${${_T}_ANDROID_KEY_PASSWORD}")
|
||||
set(ANDROID_KEY_ALIAS "${${_T}_ANDROID_KEY_ALIAS}")
|
||||
if (NOT IS_ABSOLUTE "${ANDROID_STORE_FILE}")
|
||||
set(ANDROID_STORE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/android/${ANDROID_STORE_FILE}")
|
||||
endif()
|
||||
if (${_T}_ANDROID_NEW_LOADER)
|
||||
set(ANDROID_NEW_LOADER "true")
|
||||
else()
|
||||
set(ANDROID_NEW_LOADER "false")
|
||||
endif()
|
||||
set(__ANDROID_DEBUG_KEYSTORE__ "${_modules_dir}/android_debug.keystore")
|
||||
set(QT_DIR ${Qt5_ROOT})
|
||||
set(_out_json "${CMAKE_CURRENT_BINARY_DIR}/${_T}_android_deployment_settings.json")
|
||||
configure_file("${CMAKE_BINARY_DIR}/android_deployment_settings.json.in" "${_out_json}")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/android/AndroidManifest.xml.in" "${_AGD}/AndroidManifest.xml")
|
||||
configure_file("${_modules_dir}/gradle.properties.in" "${_AGD}/gradle.properties")
|
||||
set(_depstr)
|
||||
foreach (_d ${ANDROID_GRADLE_DEPENDENCIES})
|
||||
set(_depstr "${_depstr}\n ${_d}")
|
||||
endforeach()
|
||||
set(__gradle_lang)
|
||||
foreach (_l ${${_T}_LANG})
|
||||
if (NOT "x${__gradle_lang}" STREQUAL "x")
|
||||
set(__gradle_lang "${__gradle_lang}, ")
|
||||
endif()
|
||||
set(__gradle_lang "${__gradle_lang}\"${_l}\"")
|
||||
endforeach()
|
||||
if ("x${__gradle_lang}" STREQUAL "x")
|
||||
set(__gradle_lang "\"en\"")
|
||||
endif()
|
||||
file(READ "${Qt5_ROOT}/src/android/templates/build.gradle" _file)
|
||||
string(REPLACE "\ndependencies {" "\ndependencies {${_depstr}" _file "${_file}")
|
||||
string(REPLACE "\nandroid {" "\nandroid {\n${__gradle_sign}\n${__gradle_lang_start}${__gradle_lang}\n\t}\n" _file "${_file}")
|
||||
string(REPLACE "['resources']" "['res']" _file "${_file}")
|
||||
file(WRITE "${_AGD}/build.gradle" "${_file}")
|
||||
set(_gradle_home)
|
||||
if (NOT __win_host)
|
||||
set(_gradle_home "-g" "${CMAKE_BINARY_DIR}")
|
||||
endif()
|
||||
set(_CMD_ ${_CMD_} COMMAND "${Qt5_BIN}/androiddeployqt" --aux-mode --android-platform ${ANDROID_PLATFORM} --output "\"${_AGD}\"" --input "\"${_out_json}\"")
|
||||
set(_CMD_ ${_CMD_} COMMAND "${_AGD}/gradlew" ${_gradle_home} --no-daemon -p "\"${_AGD}\"" assembleDebug)
|
||||
set(_CMD_ ${_CMD_} COMMAND "${_AGD}/gradlew" ${_gradle_home} --no-daemon -p "\"${_AGD}\"" bundleRelease)
|
||||
set(_base_name "${_TV}_android_all")
|
||||
set(_CMD_ ${_CMD_} COMMAND "${CMAKE_COMMAND}" -E copy "${_AGD}/build/outputs/apk/debug/${_T}.android-debug.apk" "${_DESTINATION}/${_base_name}.apk")
|
||||
if (ANDROID_STORE_FILE)
|
||||
set(_CMD_ ${_CMD_} COMMAND "${CMAKE_COMMAND}" -E copy "${_AGD}/build/outputs/bundle/release/${_T}.android-release.aab" "${_DESTINATION}/${_base_name}.aab")
|
||||
endif()
|
||||
add_custom_target(deploy_${_T}
|
||||
# gather .app dir
|
||||
${_CMD_}
|
||||
COMMENT "Generating ${_base_name}.apk/aab"
|
||||
)
|
||||
set(_deployed "deploy_${_T}")
|
||||
endif()
|
||||
foreach (_d ${_deployed})
|
||||
add_dependencies(deploy ${_d})
|
||||
endforeach()
|
||||
endmacro()
|
||||
@@ -1,31 +0,0 @@
|
||||
# Download and unpack googletest at configure time
|
||||
configure_file(GTestCMakeLists.txt.in googletest-download/CMakeLists.txt)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||
if(result)
|
||||
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
|
||||
endif()
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||
if(result)
|
||||
message(FATAL_ERROR "Build step for googletest failed: ${result}")
|
||||
endif()
|
||||
|
||||
# Prevent overriding the parent project's compiler/linker
|
||||
# settings on Windows
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
|
||||
# Add googletest directly to our build. This defines
|
||||
# the gtest and gtest_main targets.
|
||||
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
|
||||
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
|
||||
EXCLUDE_FROM_ALL)
|
||||
|
||||
# The gtest/gtest_main targets carry header search path
|
||||
# dependencies automatically when using CMake 2.8.11 or
|
||||
# later. Otherwise we have to add them here ourselves.
|
||||
if (CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||
include_directories("${gtest_SOURCE_DIR}/include")
|
||||
endif()
|
||||
@@ -1,24 +0,0 @@
|
||||
if(${MINGW})
|
||||
if(NOT DEFINED MINGW_DIR)
|
||||
get_filename_component(MINGW_BIN ${CMAKE_CXX_COMPILER} PATH)
|
||||
get_filename_component(MINGW_DIR ${MINGW_BIN} PATH)
|
||||
find_path(MINGW_INCLUDE
|
||||
windows.h
|
||||
PATHS
|
||||
ENV INCLUDE
|
||||
${MINGW_DIR}
|
||||
${MINGW_DIR}/i686-w64-mingw32
|
||||
${MINGW_DIR}/x86_64-w64-mingw32
|
||||
PATH_SUFFIXES
|
||||
include)
|
||||
#message(STATUS "Find MinGW = ${MINGW_INCLUDE}")
|
||||
find_library(MINGW_LIB m HINTS ${MINGW_BIN}/../lib ${MINGW_INCLUDE}/../lib)
|
||||
get_filename_component(MINGW_LIB ${MINGW_LIB} PATH)
|
||||
if (NOT _MGW_MSG)
|
||||
set(_MGW_MSG 1 CACHE BOOL "msg_mingw" FORCE)
|
||||
message(STATUS "Found MinGW binary path = ${MINGW_BIN}")
|
||||
message(STATUS "Found MinGW include path = ${MINGW_INCLUDE}")
|
||||
message(STATUS "Found MinGW library path = ${MINGW_LIB}")
|
||||
endif()
|
||||
endif()
|
||||
endif(${MINGW})
|
||||
@@ -1,6 +1,6 @@
|
||||
#[[
|
||||
|
||||
Also create imported targets:
|
||||
Create imported targets:
|
||||
* PIP - main library
|
||||
* PIP::USB
|
||||
* PIP::Console
|
||||
@@ -18,85 +18,59 @@ main library
|
||||
]]
|
||||
|
||||
cmake_policy(SET CMP0011 NEW) # don`t affect includer policies
|
||||
if(WIN32)
|
||||
find_package(MinGW REQUIRED)
|
||||
endif()
|
||||
include(SHSTKMacros)
|
||||
|
||||
set(_PIP_INCDIR "${PIP_DIR}/include/pip")
|
||||
set(_PIP_LIBDIR "${PIP_DIR}/lib")
|
||||
set(_PIP_BINDIR)
|
||||
set(_PIP_FP_DP)
|
||||
shstk_set_find_dirs(pip)
|
||||
|
||||
if(MINGW_INCLUDE)
|
||||
list(APPEND _PIP_INCDIR "${MINGW_INCLUDE}/pip")
|
||||
list(APPEND _PIP_LIBDIR "${MINGW_LIB}")
|
||||
endif()
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
list(APPEND _PIP_INCDIR "${CMAKE_PREFIX_PATH}/include/pip")
|
||||
list(APPEND _PIP_LIBDIR "${CMAKE_PREFIX_PATH}/lib")
|
||||
set(__libs "usb;crypt;console;fftw;compress;io_utils;cloud;lua")
|
||||
|
||||
if (BUILDING_pip)
|
||||
#set(_libs "pip;pip_usb;pip_console;pip_crypt;pip_fftw;pip_compress;pip_opencl;pip_io_utils;pip_cloud;pip_lua")
|
||||
#set(_bins "pip_cmg;pip_rc;deploy_tool")
|
||||
#get_target_property(_path pip BINARY_DIR)
|
||||
#get_target_property(_path pip LIBRARY_OUTPUT_NAME)
|
||||
#message("${_path}")
|
||||
#set(PIP_LIBRARY "$<TARGET_FILE_DIR:pip>/$<TARGET_FILE_NAME:pip>" CACHE STRING "")
|
||||
set(PIP_LIBRARY pip CACHE STRING "")
|
||||
|
||||
set(PIP_FOUND ON CACHE BOOL "")
|
||||
else()
|
||||
if(NOT WIN32)
|
||||
list(APPEND _PIP_INCDIR "/usr/include/pip" "/usr/local/include/pip")
|
||||
list(APPEND _PIP_LIBDIR "/usr/lib" "/usr/local/lib")
|
||||
endif()
|
||||
if(APPLE)
|
||||
include_directories(/usr/local/include)
|
||||
link_directories(/usr/local/lib)
|
||||
endif()
|
||||
find_library(PIP_LIBRARY pip HINTS ${pip_LIBDIR})
|
||||
foreach (_l ${__libs})
|
||||
find_library(PIP_LIBRARY_${_l} pip_${_l} HINTS ${pip_LIBDIR})
|
||||
endforeach()
|
||||
endif()
|
||||
list(APPEND _PIP_LIBDIR "$ENV{SMSDK_DIR}/lib")
|
||||
|
||||
if(MINGW_INCLUDE)
|
||||
list(APPEND _PIP_BINDIR "${MINGW_BIN}")
|
||||
endif()
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
set(_PIP_FP_DP "NO_DEFAULT_PATH")
|
||||
list(APPEND _PIP_BINDIR "/usr/bin" "/usr/local/bin")
|
||||
|
||||
if (BUILDING_pip AND (NOT CMAKE_CROSSCOMPILING))
|
||||
set(PIP_CMG "$<TARGET_FILE_DIR:pip_cmg>/$<TARGET_FILE_NAME:pip_cmg>" CACHE STRING "")
|
||||
set(PIP_RC "$<TARGET_FILE_DIR:pip_rc>/$<TARGET_FILE_NAME:pip_rc>" CACHE STRING "")
|
||||
set(PIP_DEPLOY_TOOL "$<TARGET_FILE_DIR:deploy_tool>/$<TARGET_FILE_NAME:deploy_tool>" CACHE STRING "")
|
||||
else()
|
||||
list(APPEND _PIP_BINDIR "${CMAKE_PREFIX_PATH}/bin")
|
||||
find_program(PIP_CMG pip_cmg${pip_BINEXT} HINTS ${pip_BINDIR} ${pip_FIND_PROGRAM_ARG})
|
||||
find_program(PIP_RC pip_rc${pip_BINEXT} HINTS ${pip_BINDIR} ${pip_FIND_PROGRAM_ARG})
|
||||
find_program(PIP_DEPLOY_TOOL deploy_tool${pip_BINEXT} HINTS ${pip_BINDIR} ${pip_FIND_PROGRAM_ARG})
|
||||
endif()
|
||||
list(APPEND _PIP_BINDIR "${PIP_DIR}/bin")
|
||||
set(_pip_suffix "")
|
||||
|
||||
find_library(PIP_LIBRARY pip${_pip_suffix} HINTS ${_PIP_LIBDIR})
|
||||
find_library(PIP_USB_LIBRARY pip_usb${_pip_suffix} HINTS ${_PIP_LIBDIR})
|
||||
find_library(PIP_CONSOLE_LIBRARY pip_console${_pip_suffix} HINTS ${_PIP_LIBDIR})
|
||||
find_library(PIP_CRYPT_LIBRARY pip_crypt${_pip_suffix} HINTS ${_PIP_LIBDIR})
|
||||
find_library(PIP_FFTW_LIBRARY pip_fftw${_pip_suffix} HINTS ${_PIP_LIBDIR})
|
||||
find_library(PIP_COMPRESS_LIBRARY pip_compress${_pip_suffix} HINTS ${_PIP_LIBDIR})
|
||||
find_library(PIP_OPENCL_LIBRARY pip_opencl${_pip_suffix} HINTS ${_PIP_LIBDIR})
|
||||
find_library(PIP_IO_UTILS_LIBRARY pip_io_utils${_pip_suffix} HINTS ${_PIP_LIBDIR})
|
||||
find_library(PIP_CLOUD_LIBRARY pip_cloud HINTS${_pip_suffix} ${_PIP_LIBDIR})
|
||||
find_library(PIP_LUA_LIBRARY pip_lua HINTS${_pip_suffix} ${_PIP_LIBDIR})
|
||||
find_file(PIP_H_INCLUDE "pip.h" HINTS ${_PIP_INCDIR} $ENV{SMSDK_DIR}/include/pip)
|
||||
get_filename_component(PIP_INCLUDES ${PIP_H_INCLUDE} PATH)
|
||||
set(__ext "")
|
||||
if ("x${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "xWindows")
|
||||
set(__ext ".exe")
|
||||
if (CMAKE_CROSSCOMPILING)
|
||||
set(_PIP_FP_DP)
|
||||
endif()
|
||||
endif()
|
||||
#message("FIND \"${__ext}\" -> ${_PIP_BINDIR}")
|
||||
find_program(PIP_CMG pip_cmg${__ext} HINTS ${_PIP_BINDIR} ${_PIP_FP_DP})
|
||||
find_program(PIP_RC pip_rc${__ext} HINTS ${_PIP_BINDIR} ${_PIP_FP_DP})
|
||||
find_program(PIP_DEPLOY_TOOL deploy_tool${__ext} HINTS ${_PIP_BINDIR} ${_PIP_FP_DP})
|
||||
if (NOT PIP_LIBRARY)
|
||||
message(FATAL_ERROR "Can`t find PIP library!")
|
||||
if(PIP_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Can`t find PIP library!")
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
set(_PIP_LIBRARY_PATH_ "${PIP_LIBRARY}")
|
||||
set(_PIP_ADD_LIBS_ "")
|
||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
find_library(DL_LIBRARY dl)
|
||||
list(APPEND PIP_LIBRARY ${DL_LIBRARY})
|
||||
if (NOT DEFINED ANDROID_PLATFORM)
|
||||
find_library(PTHREAD_LIBRARY pthread)
|
||||
find_library(UTIL_LIBRARY util)
|
||||
set(_PIP_ADD_LIBS_ ${PTHREAD_LIBRARY} ${UTIL_LIBRARY})
|
||||
list(APPEND PIP_LIBRARY ${_PIP_ADD_LIBS_})
|
||||
if (NOT BUILDING_pip)
|
||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
find_library(DL_LIBRARY dl)
|
||||
list(APPEND PIP_LIBRARY ${DL_LIBRARY})
|
||||
if (NOT DEFINED ANDROID_PLATFORM)
|
||||
find_library(PTHREAD_LIBRARY pthread)
|
||||
find_library(UTIL_LIBRARY util)
|
||||
set(_PIP_ADD_LIBS_ ${PTHREAD_LIBRARY} ${UTIL_LIBRARY})
|
||||
list(APPEND PIP_LIBRARY ${_PIP_ADD_LIBS_})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if(PIP_LUA_LIBRARY)
|
||||
if(PIP_LIBRARY_lua)
|
||||
if (NOT LUA_FOUND)
|
||||
if(MINGW)
|
||||
set(LUA_INCLUDE_DIR ${MINGW_INCLUDE})
|
||||
@@ -110,62 +84,81 @@ if(PIP_LUA_LIBRARY)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT PIP_VERSION)
|
||||
include(CheckSymbolExists)
|
||||
check_symbol_exists(PIP_VERSION_NAME "${PIP_INCLUDES}/piversion.h" HAVE_PIP_VERSION)
|
||||
if (HAVE_PIP_VERSION)
|
||||
file(STRINGS "${PIP_INCLUDES}/piversion.h" _VERSION REGEX "^[ \t]*#define[ \t]+PIP_VERSION_NAME+[ \t]+.*$")
|
||||
string(REGEX MATCH "\".*\"" _VERSION ${_VERSION})
|
||||
string(LENGTH ${_VERSION} SL)
|
||||
math(EXPR SL ${SL}-2)
|
||||
string(SUBSTRING ${_VERSION} 1 ${SL} _VERSION)
|
||||
set(PIP_VERSION ${_VERSION} CACHE STRING "VERSION")
|
||||
if (NOT _PIP_MSG)
|
||||
set(_PIP_MSG 1 CACHE BOOL "msg_pip" FORCE)
|
||||
message(STATUS "Found PIP: ${_PIP_LIBRARY_PATH_} (version \"${PIP_VERSION}\")")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Can`t find PIP version file!")
|
||||
endif()
|
||||
if (NOT BUILDING_pip)
|
||||
shstk_find_header(pip PIP "pip_version.h" "${_PIP_LIBRARY_PATH_}")
|
||||
endif()
|
||||
if(PIP_FIND_VERSION VERSION_GREATER PIP_VERSION)
|
||||
message(FATAL_ERROR "PIP version ${PIP_VERSION} is available, but ${PIP_FIND_VERSION} requested!")
|
||||
endif()
|
||||
|
||||
set(__modules "USB;Crypt;Console;FFTW;Compress;IOUtils;Cloud;Lua")
|
||||
set(__module_USB "${PIP_USB_LIBRARY}" )
|
||||
set(__module_Console "${PIP_CONSOLE_LIBRARY}" )
|
||||
set(__module_Crypt "${PIP_CRYPT_LIBRARY}" )
|
||||
set(__module_FFTW "${PIP_FFTW_LIBRARY}" )
|
||||
set(__module_Compress "${PIP_COMPRESS_LIBRARY}" )
|
||||
set(__module_OpenCL "${PIP_OPENCL_LIBRARY}" )
|
||||
set(__module_IOUtils "${PIP_IO_UTILS_LIBRARY}" )
|
||||
set(__module_Cloud "${PIP_CLOUD_LIBRARY}" )
|
||||
set(__module_Lua "${PIP_LUA_LIBRARY}" )
|
||||
if((NOT TARGET PIP) AND PIP_LIBRARY)
|
||||
add_library(PIP UNKNOWN IMPORTED)
|
||||
set_target_properties(PIP PROPERTIES
|
||||
IMPORTED_LOCATION "${_PIP_LIBRARY_PATH_}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${PIP_INCLUDES}"
|
||||
INTERFACE_LINK_LIBRARIES "${_PIP_ADD_LIBS_}")
|
||||
endif()
|
||||
foreach (_m ${__modules})
|
||||
if((NOT TARGET PIP::${_m}) AND __module_${_m})
|
||||
add_library(PIP::${_m} UNKNOWN IMPORTED)
|
||||
set_target_properties(PIP::${_m} PROPERTIES
|
||||
IMPORTED_LOCATION "${__module_${_m}}"
|
||||
INTERFACE_LINK_LIBRARIES "PIP")
|
||||
endif()
|
||||
set(__module_usb USB )
|
||||
set(__module_console Console )
|
||||
set(__module_crypt Crypt )
|
||||
set(__module_fftw FFTW )
|
||||
set(__module_compress Compress )
|
||||
set(__module_opencl OpenCL )
|
||||
set(__module_io_utils IOUtils )
|
||||
set(__module_cloud Cloud )
|
||||
set(__module_lua Lua )
|
||||
|
||||
foreach (_l ${__libs})
|
||||
set( __inc_${_l} "")
|
||||
set(__deps_${_l} "")
|
||||
set(__libs_${_l} "")
|
||||
endforeach()
|
||||
if(__module_IOUtils AND __module_Crypt)
|
||||
set_target_properties(PIP::IOUtils PROPERTIES INTERFACE_LINK_LIBRARIES "PIP::Crypt")
|
||||
endif()
|
||||
if(__module_Cloud AND __module_IOUtils)
|
||||
set_target_properties(PIP::Cloud PROPERTIES INTERFACE_LINK_LIBRARIES "PIP::IOUtils")
|
||||
endif()
|
||||
if(__module_Lua)
|
||||
set_target_properties(PIP::Lua PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LUA_INCLUDE_DIR}" INTERFACE_LINK_LIBRARIES "PIP;${LUA_LIBRARIES}")
|
||||
|
||||
set( __inc_lua "${LUA_INCLUDE_DIR}")
|
||||
|
||||
set(__deps_io_utils "PIP::Crypt")
|
||||
set(__deps_cloud "PIP::IOUtils")
|
||||
|
||||
set(__libs_lua "${LUA_LIBRARIES}")
|
||||
|
||||
|
||||
if (BUILDING_pip)
|
||||
|
||||
if (NOT SET_TARGETS_pip)
|
||||
set(SET_TARGETS_pip ON CACHE BOOL "")
|
||||
#message("create aliases")
|
||||
if((NOT TARGET PIP) AND PIP_LIBRARY)
|
||||
#message("alias PIP = pip")
|
||||
add_library(PIP ALIAS pip)
|
||||
endif()
|
||||
foreach (_l ${__libs})
|
||||
set(_m ${__module_${_l}})
|
||||
if((NOT TARGET PIP::${_m}) AND TARGET pip_${_l})
|
||||
#message("alias PIP::${_m} = pip_${_l}")
|
||||
add_library(PIP::${_m} ALIAS pip_${_l})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
else()
|
||||
|
||||
#message("create interfaces")
|
||||
if((NOT TARGET PIP) AND PIP_LIBRARY)
|
||||
add_library(PIP UNKNOWN IMPORTED)
|
||||
set_target_properties(PIP PROPERTIES
|
||||
IMPORTED_LOCATION "${_PIP_LIBRARY_PATH_}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${pip_INCLUDES}"
|
||||
INTERFACE_LINK_LIBRARIES "${_PIP_ADD_LIBS_}")
|
||||
#message("imported PIP = ${PIP_LIBRARY}")
|
||||
endif()
|
||||
foreach (_l ${__libs})
|
||||
set(_m ${__module_${_l}})
|
||||
if((NOT TARGET PIP::${_m}) AND PIP_LIBRARY_${_l})
|
||||
add_library(PIP::${_m} UNKNOWN IMPORTED)
|
||||
set_target_properties(PIP::${_m} PROPERTIES
|
||||
IMPORTED_LOCATION "${PIP_LIBRARY_${_l}}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${__inc_${_l}}"
|
||||
INTERFACE_LINK_LIBRARIES "PIP;${__deps_${_l}};${__libs_${_l}}")
|
||||
#message("imported PIP::${_m} = ${PIP_LIBRARY_${_l}} ${__deps_${_l}} ${__libs_${_l}} ${__inc_${_l}}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
endif()
|
||||
|
||||
set(PIP_FOUND ON CACHE BOOL "")
|
||||
|
||||
include(PIPMacros)
|
||||
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
|
||||
<key>CFBundleLongVersionString</key>
|
||||
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>${MACOSX_BUNDLE_SIGNATURE}</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<string>True</string>
|
||||
<key>NSSupportsAutomaticTermination</key>
|
||||
<true/>
|
||||
<key>NSSupportsSuddenTermination</key>
|
||||
<true/>
|
||||
${MACOSX_BUNDLE_PRIVACIES}
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -85,7 +85,6 @@ macro(pip_resources RESULT INPUT)
|
||||
set(SRC_RC_OUT "${RC_OUT}")
|
||||
set(RC_OUT ${CMAKE_CURRENT_BINARY_DIR}/${RC_FILE})
|
||||
set(${RESULT} ${${RESULT}} ${RC_OUT})
|
||||
set(CCM_FILES)
|
||||
if(IS_ABSOLUTE "${INPUT}")
|
||||
set(RC_FILES "${INPUT}")
|
||||
else()
|
||||
@@ -96,7 +95,7 @@ macro(pip_resources RESULT INPUT)
|
||||
set(PIP_DLL_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif()
|
||||
set(RC_DEPS ${RC_FILES})
|
||||
if(NOT PIP_BUILD)
|
||||
if(NOT BUILDING_pip)
|
||||
execute_process(COMMAND "${PIP_RC}" -l -i "${RC_FILES}"
|
||||
WORKING_DIRECTORY ${PIP_DLL_DIR}
|
||||
OUTPUT_VARIABLE RC_LIST)
|
||||
|
||||
@@ -1,136 +0,0 @@
|
||||
# Based on the Qt 5 processor detection code, so should be very accurate
|
||||
# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h
|
||||
# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64)
|
||||
|
||||
# Regarding POWER/PowerPC, just as is noted in the Qt source,
|
||||
# "There are many more known variants/revisions that we do not handle/detect."
|
||||
|
||||
set(archdetect_c_code "
|
||||
#if defined(__aarch64__)
|
||||
#error cmake_ARCH arm64
|
||||
#elif defined(__arm__) || defined(__TARGET_ARCH_ARM)
|
||||
#if defined(__ARM_ARCH_7__) \\
|
||||
|| defined(__ARM_ARCH_7A__) \\
|
||||
|| defined(__ARM_ARCH_7R__) \\
|
||||
|| defined(__ARM_ARCH_7M__) \\
|
||||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7)
|
||||
#error cmake_ARCH armv7
|
||||
#elif defined(__ARM_ARCH_6__) \\
|
||||
|| defined(__ARM_ARCH_6J__) \\
|
||||
|| defined(__ARM_ARCH_6T2__) \\
|
||||
|| defined(__ARM_ARCH_6Z__) \\
|
||||
|| defined(__ARM_ARCH_6K__) \\
|
||||
|| defined(__ARM_ARCH_6ZK__) \\
|
||||
|| defined(__ARM_ARCH_6M__) \\
|
||||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6)
|
||||
#error cmake_ARCH armv6
|
||||
#elif defined(__ARM_ARCH_5TEJ__) \\
|
||||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5)
|
||||
#error cmake_ARCH armv5
|
||||
#else
|
||||
#error cmake_ARCH arm
|
||||
#endif
|
||||
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
|
||||
#error cmake_ARCH i386
|
||||
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
|
||||
#error cmake_ARCH x86_64
|
||||
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
|
||||
#error cmake_ARCH ia64
|
||||
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\
|
||||
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\
|
||||
|| defined(_M_MPPC) || defined(_M_PPC)
|
||||
#if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
|
||||
#error cmake_ARCH ppc64
|
||||
#else
|
||||
#error cmake_ARCH ppc
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#error cmake_ARCH unknown
|
||||
")
|
||||
|
||||
# Set ppc_support to TRUE before including this file or ppc and ppc64
|
||||
# will be treated as invalid architectures since they are no longer supported by Apple
|
||||
|
||||
function(target_architecture output_var)
|
||||
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
|
||||
# On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set
|
||||
# First let's normalize the order of the values
|
||||
|
||||
# Note that it's not possible to compile PowerPC applications if you are using
|
||||
# the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we
|
||||
# disable it by default
|
||||
# See this page for more information:
|
||||
# http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4
|
||||
|
||||
# Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime.
|
||||
# On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise.
|
||||
|
||||
foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES})
|
||||
if("${osx_arch}" STREQUAL "ppc" AND ppc_support)
|
||||
set(osx_arch_ppc TRUE)
|
||||
elseif("${osx_arch}" STREQUAL "i386")
|
||||
set(osx_arch_i386 TRUE)
|
||||
elseif("${osx_arch}" STREQUAL "x86_64")
|
||||
set(osx_arch_x86_64 TRUE)
|
||||
elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support)
|
||||
set(osx_arch_ppc64 TRUE)
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Now add all the architectures in our normalized order
|
||||
if(osx_arch_ppc)
|
||||
list(APPEND ARCH ppc)
|
||||
endif()
|
||||
|
||||
if(osx_arch_i386)
|
||||
list(APPEND ARCH i386)
|
||||
endif()
|
||||
|
||||
if(osx_arch_x86_64)
|
||||
list(APPEND ARCH x86_64)
|
||||
endif()
|
||||
|
||||
if(osx_arch_ppc64)
|
||||
list(APPEND ARCH ppc64)
|
||||
endif()
|
||||
else()
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}")
|
||||
|
||||
enable_language(C)
|
||||
|
||||
# Detect the architecture in a rather creative way...
|
||||
# This compiles a small C program which is a series of ifdefs that selects a
|
||||
# particular #error preprocessor directive whose message string contains the
|
||||
# target architecture. The program will always fail to compile (both because
|
||||
# file is not a valid C program, and obviously because of the presence of the
|
||||
# #error preprocessor directives... but by exploiting the preprocessor in this
|
||||
# way, we can detect the correct target architecture even when cross-compiling,
|
||||
# since the program itself never needs to be run (only the compiler/preprocessor)
|
||||
try_run(
|
||||
run_result_unused
|
||||
compile_result_unused
|
||||
"${CMAKE_BINARY_DIR}"
|
||||
"${CMAKE_BINARY_DIR}/arch.c"
|
||||
COMPILE_OUTPUT_VARIABLE ARCH
|
||||
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
|
||||
)
|
||||
|
||||
# Parse the architecture name from the compiler output
|
||||
string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}")
|
||||
|
||||
# Get rid of the value marker leaving just the architecture name
|
||||
string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}")
|
||||
|
||||
# If we are compiling with an unknown architecture this variable should
|
||||
# already be set to "unknown" but in the case that it's empty (i.e. due
|
||||
# to a typo in the code), then set it to unknown
|
||||
if (NOT ARCH)
|
||||
set(ARCH unknown)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(${output_var} "${ARCH}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
Binary file not shown.
@@ -1,10 +0,0 @@
|
||||
androidBuildToolsVersion=
|
||||
androidCompileSdkVersion=@ANDROID_TARGET_SDK@
|
||||
android.bundle.enableUncompressedNativeLibs=@ANDROID_NEW_LOADER@
|
||||
buildDir=build
|
||||
qt5AndroidDir=@Qt5_ROOT@/src/android/java
|
||||
DEBUG_STORE_FILE=@__ANDROID_DEBUG_KEYSTORE__@
|
||||
RELEASE_STORE_FILE=@ANDROID_STORE_FILE@
|
||||
RELEASE_STORE_PASSWORD=@ANDROID_STORE_PASSWORD@
|
||||
RELEASE_KEY_PASSWORD=@ANDROID_KEY_PASSWORD@
|
||||
RELEASE_KEY_ALIAS=@ANDROID_KEY_ALIAS@
|
||||
@@ -167,7 +167,6 @@ public:
|
||||
inline bool isEmpty() const {return (pid_size == 0);}
|
||||
|
||||
inline T & operator [](size_t index) {return pid_data[pid_start + index];}
|
||||
inline T & at(size_t index) {return pid_data[pid_start + index];}
|
||||
inline const T & operator [](size_t index) const {return pid_data[pid_start + index];}
|
||||
inline const T & at(size_t index) const {return pid_data[pid_start + index];}
|
||||
inline T & back() {return pid_data[pid_start + pid_size - 1];}
|
||||
|
||||
@@ -206,7 +206,6 @@ public:
|
||||
return pim_content.back();
|
||||
}
|
||||
const T operator [](const Key & key) const {bool f(false); ssize_t i = _find(key, f); if (f) return pim_content[pim_index[i].index]; return T();}
|
||||
T & at(const Key & key) {return (*this)[key];}
|
||||
const T at(const Key & key) const {return (*this)[key];}
|
||||
|
||||
PIMap<Key, T> & operator <<(const PIMap<Key, T> & other) {
|
||||
|
||||
@@ -167,7 +167,6 @@ public:
|
||||
inline bool isEmpty() const {return (piv_size == 0);}
|
||||
|
||||
inline T & operator [](size_t index) {return piv_data[index];}
|
||||
inline T & at(size_t index) {return piv_data[index];}
|
||||
inline const T & operator [](size_t index) const {return piv_data[index];}
|
||||
inline const T & at(size_t index) const {return piv_data[index];}
|
||||
inline T & back() {return piv_data[piv_size - 1];}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#ifndef PIBASE_H
|
||||
#define PIBASE_H
|
||||
|
||||
#include "piversion.h"
|
||||
#include "pip_version.h"
|
||||
#include "piplatform.h"
|
||||
#include "pip_export.h"
|
||||
#include "pip_defs.h"
|
||||
|
||||
@@ -613,7 +613,7 @@ PIString PIString::trimmed() const {
|
||||
PIString & PIString::replace(int from, int count, const PIString & with) {
|
||||
count = piMini(count, length() - from);
|
||||
if (count == with.size_s())
|
||||
memcpy(&(at(from)), &(with.at(0)), count * sizeof(PIChar));
|
||||
memcpy(PIDeque<PIChar>::data(from), static_cast<PIDeque<PIChar>>(with).data(), count * sizeof(PIChar));
|
||||
else {
|
||||
remove(from, count);
|
||||
PIDeque<PIChar>::insert(from, with);
|
||||
@@ -671,7 +671,7 @@ PIString & PIString::replaceAll(const PIString & what, const char with) {
|
||||
}
|
||||
if (!match) continue;
|
||||
if (dl > 0) PIDeque<PIChar>::remove(i, dl);
|
||||
at(i) = PIChar(with);
|
||||
(*this)[i] = PIChar(with);
|
||||
//i -= l;
|
||||
}
|
||||
return *this;
|
||||
@@ -682,7 +682,7 @@ PIString & PIString::replaceAll(const char what, const char with) {
|
||||
int l = length();
|
||||
for (int i = 0; i < l; ++i) {
|
||||
if (at(i) == what)
|
||||
at(i) = with;
|
||||
(*this)[i] = with;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -1166,18 +1166,6 @@ PIString & PIString::setReadableSize(llong bytes) {
|
||||
}
|
||||
|
||||
|
||||
inline char chrUpr(char c) {
|
||||
if (c >= 'a' && c <= 'z') return c + 'A' - 'a';
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
inline char chrLwr(char c) {
|
||||
if (c >= 'A' && c <= 'Z') return c + 'a' - 'A';
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
const static PIString _versionDelims_ = PIStringAscii("._-+");
|
||||
|
||||
|
||||
|
||||
@@ -101,12 +101,6 @@ public:
|
||||
* Example: \snippet pistring.cpp PIString::char* */
|
||||
operator const char*() {return data();}
|
||||
|
||||
//! Return symbol at index "pos"
|
||||
PIChar operator [](const int pos) const {return at(pos);}
|
||||
|
||||
//! Return reference to symbol at index "pos"
|
||||
PIChar & operator [](const int pos) {return at(pos);}
|
||||
|
||||
//! Compare operator
|
||||
bool operator ==(const PIString & str) const;
|
||||
|
||||
@@ -790,9 +784,6 @@ inline PIString operator +(const char c, const PIString & f) {return PIChar(c) +
|
||||
//! \relatesalso PIString \brief Return concatenated string
|
||||
inline PIString operator +(const PIString & f, const char c) {return f + PIChar(c);}
|
||||
|
||||
inline char chrUpr(char c);
|
||||
inline char chrLwr(char c);
|
||||
|
||||
|
||||
int versionCompare(const PIString & v0, const PIString & v1, int components = 6);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
|
||||
//! \brief Trim all strings
|
||||
//! \details Example: \snippet pistring.cpp PIStringList::trim
|
||||
PIStringList & trim() {for (uint i = 0; i < size(); ++i) at(i).trim(); return *this;}
|
||||
PIStringList & trim() {for (uint i = 0; i < size(); ++i) (*this)[i].trim(); return *this;}
|
||||
|
||||
//! Return sum of lengths of all strings
|
||||
uint contentSize() {uint s = 0; for (uint i = 0; i < size(); ++i) s += at(i).size(); return s;}
|
||||
|
||||
@@ -43,6 +43,7 @@ PICAN::PICAN(const PIString & path, PIIODevice::DeviceMode mode) : PIIODevice(pa
|
||||
setThreadedReadBufferSize(256);
|
||||
setPath(path);
|
||||
can_id = 0;
|
||||
sock = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,10 +26,6 @@
|
||||
# include <unistd.h>
|
||||
# include <cstdlib>
|
||||
#endif
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
#endif
|
||||
|
||||
|
||||
/*! \class PIGPIO
|
||||
|
||||
@@ -90,7 +90,7 @@ bool PIConditionVariable::waitFor(PIMutex &lk, int timeoutMs) {
|
||||
#ifdef WINDOWS
|
||||
isNotTimeout = SleepConditionVariableCS(&PRIVATE->nativeHandle, (PCRITICAL_SECTION)lk.handle(), timeoutMs) != 0;
|
||||
#else
|
||||
timespec abstime = {.tv_sec = timeoutMs / 1000, .tv_nsec = timeoutMs % 1000000 * 1000000};
|
||||
timespec abstime = {.tv_sec = timeoutMs / 1000, .tv_nsec = timeoutMs % 1000 * 1000000};
|
||||
isNotTimeout = pthread_cond_timedwait(&PRIVATE->nativeHandle, (pthread_mutex_t*)lk.handle(), &abstime) == 0;
|
||||
#endif
|
||||
if (PRIVATE->isDestroying) return false;
|
||||
@@ -111,7 +111,7 @@ bool PIConditionVariable::waitFor(PIMutex& lk, int timeoutMs, const std::functio
|
||||
timeoutMs - (int)measurer.elapsed_m()) == 0;
|
||||
#else
|
||||
int timeoutCurr = timeoutMs - (int)measurer.elapsed_m();
|
||||
timespec abstime = {.tv_sec = timeoutCurr / 1000, .tv_nsec = timeoutCurr % 1000000 * 1000000};
|
||||
timespec abstime = {.tv_sec = timeoutCurr / 1000, .tv_nsec = timeoutCurr % 1000 * 1000000};
|
||||
bool isTimeout = pthread_cond_timedwait(&PRIVATE->nativeHandle, (pthread_mutex_t*)lk.handle(), &abstime) != 0;
|
||||
#endif
|
||||
if (isTimeout) return false;
|
||||
|
||||
@@ -56,8 +56,6 @@ private:
|
||||
std::atomic_bool isShutdown_;
|
||||
PIBlockingQueue<std::function<void()> > taskQueue;
|
||||
PIVector<PIThread*> threadPool;
|
||||
bool queue_own;
|
||||
|
||||
};
|
||||
|
||||
#endif // PITHREADPOOLEXECUTOR_H
|
||||
|
||||
@@ -6,7 +6,7 @@ macro(pip_test NAME LIBS)
|
||||
set(_target pip_${NAME}_test)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PIP_ROOT_BINARY_DIR}")
|
||||
add_executable(${_target} ${_CPPS} ${_HDRS})
|
||||
target_link_libraries(${_target} pip ${LIBS} gtest_main gmock_main)
|
||||
target_link_libraries(${_target} pip ${LIBS} gtest_main gmock_main)
|
||||
add_test(NAME ${_target} COMMAND tests)
|
||||
add_custom_target(${_target}_perform ALL COMMAND ${_target})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY)
|
||||
@@ -17,3 +17,4 @@ endmacro()
|
||||
# Concurrent tests
|
||||
pip_test(concurrent "")
|
||||
pip_test(math "")
|
||||
pip_test(core "")
|
||||
|
||||
3008
tests/core/pistringTest.cpp
Normal file
3008
tests/core/pistringTest.cpp
Normal file
@@ -0,0 +1,3008 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "pistring.h"
|
||||
#include "pistringlist.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_pichar){
|
||||
PIString str1 = "AB C";
|
||||
const PIChar str2 = " ";
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "AB C ");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_pichar_zero1){
|
||||
PIString str1 = "";
|
||||
const PIChar str2 = "D";
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "D");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_pichar_zero2){
|
||||
PIString str1 = "AB C";
|
||||
const PIChar str2 = "";
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "AB C");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_pichar_zero_zero){
|
||||
PIString str1;
|
||||
const PIChar str2;
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_char){
|
||||
PIString str1 = "AB C";
|
||||
const char *str2 = "D D ";
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "AB CD D ");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_char_zero1){
|
||||
PIString str1 = "";
|
||||
const char *str2 = "D D ";
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "D D ");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_char_zero2){
|
||||
PIString str1 = "AB C";
|
||||
const char *str2;
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "AB C");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_char_zero_zero){
|
||||
PIString str1;
|
||||
const char *str2;
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_wchar){
|
||||
PIString str1= "AB C";
|
||||
wchar_t str2[] = L"C";
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "AB CC");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_wchar_zero1){
|
||||
PIString str1 = "";
|
||||
wchar_t str2[] = L"C";
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "C");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_wchar_zero2){
|
||||
PIString str1 = "AB C";
|
||||
wchar_t *str2;
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "AB C");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_wchar_zero_zero){
|
||||
PIString str1;
|
||||
wchar_t *str2;
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_pistring){
|
||||
PIString str1 = "AB C";
|
||||
PIString str2 = " CD ";
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "AB C CD ");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_pistring_zero1){
|
||||
PIString str1 = "";
|
||||
PIString str2 = "D DD";
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "D DD");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_pistring_zero2){
|
||||
PIString str1 = "AB C";
|
||||
PIString str2 = "";
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "AB C");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_pistring_zero_zero){
|
||||
PIString str1;
|
||||
PIString str2;
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_piByteArray){
|
||||
PIString str1 = "AB C";
|
||||
PIByteArray str2;
|
||||
str2.append('g');
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "AB Cg");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_piByteArray_zero1){
|
||||
PIString str1 = "";
|
||||
PIByteArray str2;
|
||||
str2.append('0');
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "0");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_piByteArray_zero2){
|
||||
PIString str1 = "AB C";
|
||||
PIByteArray str2;
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "AB C");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_piByteArray_zero_zero){
|
||||
PIString str1;
|
||||
PIByteArray str2;
|
||||
str1 += str2;
|
||||
ASSERT_STREQ(str1, "");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_pistring){
|
||||
PIString str1 = "New";
|
||||
ASSERT_STREQ(str1, PIString("New"));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_pichar){
|
||||
PIChar str1 = 'n';
|
||||
ASSERT_STREQ("n", PIString(str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_char){
|
||||
char str1 = 'n';
|
||||
ASSERT_STREQ("n", PIString(str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_chars){
|
||||
char str1[] = "mew";
|
||||
ASSERT_STREQ("mew", PIString(str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_wchar_t){
|
||||
wchar_t str1[] = L"gav";
|
||||
ASSERT_STREQ("gav", PIString(str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_pibyte_array){
|
||||
PIByteArray str1;
|
||||
str1.append('m');
|
||||
ASSERT_STREQ("m", PIString(str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_pichar_size){
|
||||
PIChar *str1 = new PIChar[3];
|
||||
str1[0] = 'n';
|
||||
str1[1] = 'e';
|
||||
str1[2] = 'w';
|
||||
ASSERT_STREQ("new", PIString(str1, 3));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_char_size){
|
||||
char str1[] = "good";
|
||||
ASSERT_STREQ("good", PIString(str1, 4));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_char_len){
|
||||
char str1 = 'n';
|
||||
ASSERT_STREQ("nnn", PIString(3, str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_pichar_len){
|
||||
PIChar str1 = 'n';
|
||||
ASSERT_STREQ("nnnnn", PIString(5, str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_pointer){
|
||||
PIString str1 = "testing";
|
||||
const char *point = str1.operator const char *();
|
||||
ASSERT_STREQ("testing", point);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_symbol){
|
||||
PIString str1 = "testing";
|
||||
PIChar symbo = "i";
|
||||
ASSERT_EQ(symbo, str1[4]);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_compare_pistring_true){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 == str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_compare_pistring_false){
|
||||
PIString str1 = "tes";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_FALSE(str1 == str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_compare_pichar_true){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_TRUE(str1 == str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_compare_pichar_false){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "p";
|
||||
ASSERT_FALSE(str1 == str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_compare_char_true){
|
||||
PIString str1 = "test";
|
||||
char str2[] = "test";
|
||||
ASSERT_TRUE(str1 == str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_compare_char_false){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "test";
|
||||
ASSERT_FALSE(str1 == str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_encompare_pistring_false){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_FALSE(str1 != str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_encompare_pistring_true){
|
||||
PIString str1 = "tes";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 != str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_encompare_pichar_false){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_FALSE(str1 != str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_encompare_pichar_true){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "p";
|
||||
ASSERT_TRUE(str1 != str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_encompare_char_false){
|
||||
PIString str1 = "test";
|
||||
char str2[] = "test";
|
||||
ASSERT_FALSE(str1 != str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_encompare_char_true){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "test";
|
||||
ASSERT_TRUE(str1 != str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_pistring_true){
|
||||
PIString str1 = "testin";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_pistring_false){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testin";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_pistring_false_equal){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_pichar_true){
|
||||
PIString str1 = "a";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_TRUE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_pichar_false){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "a";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_pichar_false_equal){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_char_true){
|
||||
PIString str1 = "a";
|
||||
char str2[] = "t";
|
||||
ASSERT_TRUE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_char_false){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "a";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_char_false_equal){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "t";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_pistring_true){
|
||||
PIString str1 = "testin";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str2 > str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_pistring_false){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testin";
|
||||
ASSERT_FALSE(str2 > str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_pistring_false_equal){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_FALSE(str1 > str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_pichar_true){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "a";
|
||||
ASSERT_TRUE(str1 > str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_pichar_false){
|
||||
PIString str1 = "a";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_FALSE(str1 > str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_pichar_false_equal){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_FALSE(str1 > str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_char_true){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "a";
|
||||
ASSERT_TRUE(str1 > str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_char_false){
|
||||
PIString str1 = "a";
|
||||
char str2[] = "t";
|
||||
ASSERT_FALSE(str1 > str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_char_false_equal){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "t";
|
||||
ASSERT_FALSE(str1 > str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_eq_pistring_true){
|
||||
PIString str1 = "testin";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_eq_pistring_false){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testin";
|
||||
ASSERT_FALSE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_pistring_true_equal){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_eq_pichar_true){
|
||||
PIString str1 = "a";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_eq_pichar_false){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "a";
|
||||
ASSERT_FALSE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_eq_pichar_true_equal){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_eq_char_true){
|
||||
PIString str1 = "a";
|
||||
char str2[] = "t";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_eq_char_false){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "a";
|
||||
ASSERT_FALSE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_eq_char_true_equal){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "t";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_pistring_true){
|
||||
PIString str1 = "testin";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str2 >= str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_pistring_false){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testin";
|
||||
ASSERT_FALSE(str2 >= str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_pistring_true_equal){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 >= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_pichar_true){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "a";
|
||||
ASSERT_TRUE(str1 >= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_pichar_false){
|
||||
PIString str1 = "a";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_FALSE(str1 >= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_pichar_true_equal){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_TRUE(str1 >= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_char_true){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "a";
|
||||
ASSERT_TRUE(str1 >= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_char_false){
|
||||
PIString str1 = "a";
|
||||
char str2[] = "t";
|
||||
ASSERT_FALSE(str1 >= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_char_true_equal){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "t";
|
||||
ASSERT_TRUE(str1 >= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_pistring){
|
||||
PIString str1 = "shift";
|
||||
PIString str2 = " good";
|
||||
str1 << str2;
|
||||
ASSERT_STREQ("shift good", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_pichar){
|
||||
PIString str1 = "shif";
|
||||
PIChar str2 = 't';
|
||||
str1 << str2;
|
||||
ASSERT_STREQ("shift", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_char){
|
||||
PIString str1 = "shif";
|
||||
char str2[] = "t chat";
|
||||
str1 << str2;
|
||||
ASSERT_STREQ("shift chat", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_wchar_t){
|
||||
PIString str1 = "shif";
|
||||
wchar_t str2[] = L"t cc";
|
||||
str1 << str2;
|
||||
ASSERT_STREQ("shift cc", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_int){
|
||||
PIString str1 = "shift ";
|
||||
int numb = -2147483648;
|
||||
str1 << numb;
|
||||
ASSERT_STREQ("shift -2147483648", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_uint){
|
||||
PIString str1 = "shift ";
|
||||
uint numb = 4294967295;
|
||||
str1 << numb;
|
||||
ASSERT_STREQ("shift 4294967295", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_short){
|
||||
PIString str1 = "shift ";
|
||||
short numb = -32768;
|
||||
str1 << numb;
|
||||
ASSERT_STREQ("shift -32768", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_ushort){
|
||||
PIString str1 = "shift ";
|
||||
ushort numb = 65535;
|
||||
str1 << numb;
|
||||
ASSERT_STREQ("shift 65535", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_long){
|
||||
PIString str1 = "shift ";
|
||||
long numb = -2147483648;
|
||||
str1 << numb;
|
||||
ASSERT_STREQ("shift -2147483648", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_ulong){
|
||||
PIString str1 = "shift ";
|
||||
ulong numb = 4294967295;
|
||||
str1 << numb;
|
||||
ASSERT_STREQ("shift 4294967295", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_llong){
|
||||
PIString str1 = "shift ";
|
||||
llong numb = -9223372036854775807;
|
||||
str1 << numb;
|
||||
ASSERT_STREQ("shift -9223372036854775807", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_ullong){
|
||||
PIString str1 = "shift ";
|
||||
ullong numb = 1844674407370955161;
|
||||
str1 << numb;
|
||||
ASSERT_STREQ("shift 1844674407370955161", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_float){
|
||||
PIString str1 = "shift ";
|
||||
float numb = -67.88999939;
|
||||
str1 << numb;
|
||||
ASSERT_STREQ("shift -67.88999939", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_double){
|
||||
PIString str1 = "shift ";
|
||||
double numb = 13.34300000;
|
||||
str1 << numb;
|
||||
|
||||
ASSERT_STREQ("shift 13.34300000", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, prepend){
|
||||
PIString str1 = "idea";
|
||||
PIString str2 = "Good ";
|
||||
str1.prepend(str2);
|
||||
ASSERT_STREQ("Good idea", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, append){
|
||||
PIString str1 = "Good";
|
||||
PIString str2 = " idea";
|
||||
str1.append(str2);
|
||||
ASSERT_STREQ("Good idea", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, mid){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("fo", str1.mid(10, 2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, mid_len_0){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("", str1.mid(10, 0));
|
||||
}
|
||||
|
||||
|
||||
TEST(PIString_Tests, mid_start_more){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("", str1.mid(1000, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, mid_len_minus){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("for new project 144", str1.mid(10, -2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, mid_len_more){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("for new project 144", str1.mid(10, 100));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, subString){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("for new project 144", str1.mid(10, 46));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, mid_minus){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("Good idea for new project 144", str1.mid(-10, 47));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, subString_minus){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("Go", str1.mid(-10, 12));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, left){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("Go", str1.left(2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, left_minus){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("", str1.left(-2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, right){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("44", str1.right(2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, right_minus){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("", str1.right(-2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutMid){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("Good for new project 144", str1.cutMid(5,5));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutMid_len_zero){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("Good idea for new project 144", str1.cutMid(5,0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutMid_len_min){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("Good ", str1.cutMid(5,-2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutMid_minus){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("ood idea for new project 144", str1.cutMid(-5, 6));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutMid_zero){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("Good idea for new project 144", str1.cutMid(-5, 5));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutleft){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("od idea for new project 144", str1.cutLeft(2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutleft_minus){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("Good idea for new project 144", str1.cutLeft(-2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutright){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("Good idea for new project 1", str1.cutRight(2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutright_minus){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("Good idea for new project 144", str1.cutRight(-2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, trim){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
ASSERT_STREQ("Good idea for new project 144", str1.trim());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, trim_without){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("Good idea for new project 144", str1.trim());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, trim_link){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString &str2 = str1.trim();
|
||||
str1 = "link";
|
||||
ASSERT_STREQ("link", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, trimmed){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
ASSERT_STREQ("Good idea for new project 144", str1.trimmed());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, trimmed_without){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
ASSERT_STREQ("Good idea for new project 144", str1.trimmed());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
ASSERT_STREQ(" Good thin for new project 144 ", str1.replace(6,4, "thin"));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_more){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
ASSERT_STREQ(" Good thin", str1.replace(6,100, "thin"));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_link){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString &str2 = str1.replace(6,4, "thin");
|
||||
str1 = "link";
|
||||
ASSERT_STREQ("link", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_minus){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
ASSERT_STREQ("BAD idea for new project 144 ", str1.replace(0, 5, "BAD"));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_zero){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
ASSERT_STREQ("thin Good idea for new project 144 ", str1.replace(0, 0, "thin"));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_all){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
ASSERT_STREQ("BAD", str1.replaced(0, 100, "BAD"));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaced){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
ASSERT_STREQ(" Good thin for new project 144 ", str1.replaced(6,4, "thin"));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaced_minus){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
ASSERT_STREQ("BAD idea for new project 144 ", str1.replaced(0, 5, "BAD"));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaced_zero){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
ASSERT_STREQ("thin Good idea for new project 144 ", str1.replaced(0, 0, "thin"));
|
||||
}
|
||||
|
||||
|
||||
TEST(PIString_Tests, replaced_all){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
ASSERT_STREQ("thin", str1.replaced(0, 100, "thin"));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_str){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replace("Good", "bad", &ok);
|
||||
ASSERT_STREQ(" bad idea for new Good project 144 ", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_str_link){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
PIString &str2 = str1.replace("Good", "bad", &ok);
|
||||
str1 = "link";
|
||||
ASSERT_STREQ("link", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_str_zero){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replace("", "bad", &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_str_true){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replace("Good", "bad", &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_str_delete){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replace("Good", "", &ok);
|
||||
ASSERT_STREQ(" idea for new Good project 144 ", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaced_str){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
PIString str2 = str1.replaced("Good", "bad", &ok);
|
||||
ASSERT_STREQ(" bad idea for new Good project 144 ", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaced_str_zero){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replaced("", "bad", &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaced_str_true){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replaced("Good", "bad", &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaced_delete){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
PIString str2 = str1.replaced("Good", "", &ok);
|
||||
ASSERT_STREQ(" idea for new Good project 144 ", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaceall){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
str1.replaceAll("Good", "bad");
|
||||
ASSERT_STREQ(" bad idea for new bad project 144 ", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaceall_no_find){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
str1.replaceAll("God", "bad");
|
||||
ASSERT_STREQ(" Good idea for new Good project 144 ", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaceall_str){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
PIString str2 = str1.replaceAll("Good", "bad");
|
||||
ASSERT_STREQ(" bad idea for new bad project 144 ", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaceall_str_no_find){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
PIString str2 = str1.replaceAll("God", "bad");
|
||||
ASSERT_STREQ(" Good idea for new Good project 144 ", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaceall_link){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
PIString &str2 = str1.replaceAll("Good", "bad");
|
||||
ASSERT_STREQ(" bad idea for new bad project 144 ", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaceall_link_change){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
PIString &str2 = str1.replaceAll("Good", "bad");
|
||||
str1 = "link";
|
||||
ASSERT_STREQ("link", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, repeat){
|
||||
PIString str1 = "string ";
|
||||
PIString str2 = str1.repeat(6);
|
||||
ASSERT_STREQ("string string string string string string ", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, repeat_zero){
|
||||
PIString str1 = "string ";
|
||||
PIString str2 = str1.repeat(0);
|
||||
ASSERT_STREQ("string ", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, repeat_link){
|
||||
PIString str1 = "string ";
|
||||
PIString &str2 = str1.repeat(6);
|
||||
str1 = "link";
|
||||
ASSERT_STREQ("link", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, repeated){
|
||||
PIString str1 = "string ";
|
||||
str1.repeat(6);
|
||||
ASSERT_STREQ("string string string string string string ", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, repeated_zero){
|
||||
PIString str1 = "string ";
|
||||
str1.repeat(0);
|
||||
ASSERT_STREQ("string ", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, insert_char){
|
||||
PIString str1 = "strng ";
|
||||
char sym = 'i';
|
||||
str1.insert(3, sym);
|
||||
ASSERT_STREQ("string ", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, insert_pichar){
|
||||
PIString str1 = "strng ";
|
||||
PIChar sym = 'i';
|
||||
str1.insert(3, sym);
|
||||
ASSERT_STREQ("string ", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, insert_pistring){
|
||||
PIString str1 = "string out";
|
||||
PIString str2 = " go";
|
||||
str1.insert(6, str2);
|
||||
ASSERT_STREQ("string go out", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, insert_chars){
|
||||
PIString str1 = "see boy";
|
||||
char str2[] = " big";
|
||||
str1.insert(3, str2);
|
||||
ASSERT_STREQ("see big boy", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, expandRightTo){
|
||||
PIString str1 = "see boy ";
|
||||
PIChar symbol = "x";
|
||||
str1.expandRightTo(11, symbol);
|
||||
ASSERT_STREQ("see boy xxx", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, expandRightTo_null){
|
||||
PIString str1 = "see boy ";
|
||||
PIChar symbol = "x";
|
||||
str1.expandRightTo(0, symbol);
|
||||
ASSERT_STREQ("see boy ", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, expandLeftTo){
|
||||
PIString str1 = " see boy";
|
||||
PIChar symbol = "x";
|
||||
str1.expandLeftTo(11, symbol);
|
||||
ASSERT_STREQ("xxx see boy", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, expandLeftTo_null){
|
||||
PIString str1 = "see boy ";
|
||||
PIChar symbol = "x";
|
||||
str1.expandLeftTo(0, symbol);
|
||||
ASSERT_STREQ("see boy ", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, quote){
|
||||
PIString str1 = "see boy";
|
||||
PIChar symbol = " ";
|
||||
str1.quote(symbol);
|
||||
ASSERT_STREQ(" see boy ", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, quote_link){
|
||||
PIString str1 = "see boy";
|
||||
PIChar symbol = " ";
|
||||
PIString &str2 = str1.quote(symbol);
|
||||
str1 = "link";
|
||||
ASSERT_STREQ("link", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, quoted){
|
||||
PIString str1 = "see boy";
|
||||
PIChar symbol = " ";
|
||||
PIString str2 = str1.quoted(symbol);
|
||||
ASSERT_STREQ(" see boy ", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, reverse){
|
||||
PIString str1 = "see boy";
|
||||
PIString &str2 = str1.reverse();
|
||||
ASSERT_STREQ("yob ees", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, reverse_link){
|
||||
PIString str1 = "see boy";
|
||||
PIString &str2 = str1.reverse();
|
||||
str1 = "yes";
|
||||
ASSERT_STREQ("yes", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, reversed){
|
||||
PIString str1 = "see boy";
|
||||
PIString str2 = str1.reversed();
|
||||
ASSERT_STREQ("yob ees", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, elide){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString &str2 = str1.elide(8, 1);
|
||||
ASSERT_STREQ("BMSTU ..", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, elide_small){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString &str2 = str1.elide(2, 1);
|
||||
ASSERT_STREQ("..", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, elide_all){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString &str2 = str1.elide(100, 1);
|
||||
ASSERT_STREQ("BMSTU is best university in space", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, elide_link){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString &str2 = str1.elide(8, 1);
|
||||
str1 = "space";
|
||||
ASSERT_STREQ("space", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, elided){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.elided(8, 1);
|
||||
ASSERT_STREQ("BMSTU ..", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takemid){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeMid(9, 4);
|
||||
ASSERT_STREQ("best", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takeleft){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeLeft(5);
|
||||
ASSERT_STREQ("BMSTU", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takeright){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeRight(5);
|
||||
ASSERT_STREQ("space", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takesymbol){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeSymbol();
|
||||
ASSERT_STREQ("B", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takesymbol_with_rubbish){
|
||||
PIString str1 = " \t \n \r BMSTU is best university in space";
|
||||
PIString str2 = str1.takeSymbol();
|
||||
ASSERT_STREQ("B", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takesymbol_without){
|
||||
PIString str1 = " \t \n \r ";
|
||||
PIString str2 = str1.takeSymbol();
|
||||
ASSERT_STREQ("", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takeword){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeWord();
|
||||
ASSERT_STREQ("BMSTU", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takeword_space){
|
||||
PIString str1 = " \r\n\tBMSTU is best university in space";
|
||||
PIString str2 = str1.takeWord();
|
||||
ASSERT_STREQ("BMSTU", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takeword_without_word){
|
||||
PIString str1 = " \r\n\t";
|
||||
PIString str2 = str1.takeWord();
|
||||
ASSERT_STREQ("", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takecword){
|
||||
PIString str1 = "_6 BMSTU is best university in space";
|
||||
PIString str2 = str1.takeCWord();
|
||||
ASSERT_STREQ("_6", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takecword_space){
|
||||
PIString str1 = " \t\r\n_6 BMSTU is best university in space";
|
||||
PIString str2 = str1.takeCWord();
|
||||
ASSERT_STREQ("_6", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takecword_space_w){
|
||||
PIString str1 = " \t\r\n BMSTU is best university in space";
|
||||
PIString str2 = str1.takeCWord();
|
||||
ASSERT_STREQ("BMSTU", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takecword_not_cword){
|
||||
PIString str1 = " \t\r\n ";
|
||||
PIString str2 = str1.takeCWord();
|
||||
ASSERT_STREQ("", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takeline){
|
||||
PIString str1 = "BMSTU is best\n university in space";
|
||||
PIString str2 = str1.takeLine();
|
||||
ASSERT_STREQ("BMSTU is best", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takeline_without){
|
||||
PIString str1 = "BMSTU is best";
|
||||
PIString str2 = str1.takeLine();
|
||||
ASSERT_STREQ("", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takeline_first){
|
||||
PIString str1 = "\nBMSTU is best";
|
||||
PIString str2 = str1.takeLine();
|
||||
ASSERT_STREQ("", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takenumber){
|
||||
PIString str1 = "6.6";
|
||||
PIString str2 = str1.takeNumber();
|
||||
ASSERT_STREQ("6.6", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takenumber_sign){
|
||||
PIString str1 = "-66";
|
||||
PIString str2 = str1.takeNumber();
|
||||
ASSERT_STREQ("-66", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takenumber_suffix){
|
||||
PIString str1 = "66L";
|
||||
PIString str2 = str1.takeNumber();
|
||||
ASSERT_STREQ("66L", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takerange){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeRange('B', 'i', ' ');
|
||||
ASSERT_STREQ("MSTU is best un", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takerange_without_shield){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeRange('B', 'i');
|
||||
ASSERT_STREQ("MSTU ", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takerange_space){
|
||||
PIString str1 = " \t\r\nBMSTU is best university in space";
|
||||
PIString str2 = str1.takeRange('B', 'i', ' ');
|
||||
ASSERT_STREQ("MSTU is best un", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takerange_without_shield_space){
|
||||
PIString str1 = " \t\r\nBMSTU is best university in space";
|
||||
PIString str2 = str1.takeRange('B', 'i');
|
||||
ASSERT_STREQ("MSTU ", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, inBrackets){
|
||||
PIString str1 = "BMSTU is (best) university in space";
|
||||
PIString str2 = str1.inBrackets('(', ')');
|
||||
ASSERT_STREQ("best", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, inBrackets_end_start){
|
||||
PIString str1 = "BMSTU )is (best) university in space";
|
||||
PIString str2 = str1.inBrackets('(', ')');
|
||||
ASSERT_STREQ("best", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, inBrackets_without){
|
||||
PIString str1 = "BMSTU )is (best) university in space";
|
||||
PIString str2 = str1.inBrackets('0', '1');
|
||||
ASSERT_STREQ("", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, lenghtascii){
|
||||
PIString str1 = "BMSTU is (best) university in space";
|
||||
int size = str1.lengthAscii();
|
||||
ASSERT_EQ(35, size);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, data){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
const char *data = str1.data();
|
||||
ASSERT_STREQ("BMSTU is (best) university in space\n", data);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, dataconsole){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
const char *data = str1.dataConsole();
|
||||
ASSERT_STREQ("BMSTU is (best) university in space\n", data);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, dataUTF8){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
const char *data = str1.dataUTF8();
|
||||
ASSERT_STREQ("BMSTU is (best) university in space\n", data);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, dataAScii){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
const char *data = str1.dataAscii();
|
||||
ASSERT_STREQ("BMSTU is (best) university in space\n", data);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, hash){
|
||||
const PIString str1 = "B";
|
||||
uint h = str1.hash();
|
||||
ASSERT_EQ(3912571919, h);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, toByteArray){
|
||||
const PIString str1 = "C";
|
||||
PIByteArray h = str1.toByteArray();
|
||||
ASSERT_EQ(67, h.at(0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, toUTF8){
|
||||
const PIString str1 = "C";
|
||||
PIByteArray h = str1.toUTF8();
|
||||
ASSERT_EQ(67, h.at(0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, tocharset){
|
||||
const PIString str1 = "B";
|
||||
PIByteArray h = str1.toCharset("c");
|
||||
ASSERT_EQ(66, h.at(0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, toUTF8_empty){
|
||||
PIString str1;
|
||||
str1.toUTF8();
|
||||
ASSERT_EQ(0, str1.size());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, tocharset_empty){
|
||||
PIString str1 = "";
|
||||
str1.toCharset("c");
|
||||
ASSERT_EQ(0, str1.size());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, split){
|
||||
PIString str1 = " mirrow best mirrow ";
|
||||
PIStringList list = str1.split("best");
|
||||
ASSERT_STREQ(list[1], list[0]);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, split_empty){
|
||||
PIString str1 = "";
|
||||
PIStringList list = str1.split("best");
|
||||
ASSERT_EQ(0, list.size());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, split_empty_delim){
|
||||
PIString str1 = " mirrow best mirrow ";
|
||||
PIStringList list = str1.split("");
|
||||
ASSERT_EQ(0, list.size());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, split_not_delim){
|
||||
PIString str1 = " mirrow best mirrow ";
|
||||
PIStringList list = str1.split("tr");
|
||||
ASSERT_STREQ(list[0], " mirrow best mirrow ");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, toUpperCase){
|
||||
PIString str1 = " miRrow ";
|
||||
PIString str2 = str1.toUpperCase();
|
||||
ASSERT_STREQ(" MIRROW ", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, toLowerCase){
|
||||
PIString str1 = " MIrROW ";
|
||||
PIString str2 = str1.toLowerCase();
|
||||
ASSERT_STREQ(" mirrow ", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, toNativeDecimalPoints){
|
||||
PIString str1 = "4546,878";
|
||||
PIString str2 = str1.toNativeDecimalPoints();
|
||||
ASSERT_STREQ("4546.878", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, contains_char){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = '\n';
|
||||
ASSERT_TRUE(str1.contains(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, contains_char_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = '0';
|
||||
ASSERT_FALSE(str1.contains(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, contains_picahr){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIChar s = 'i';
|
||||
ASSERT_TRUE(str1.contains(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, contains_pichar_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIChar s = '0';
|
||||
ASSERT_FALSE(str1.contains(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, contains_cahrs){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s[] = "BMSTU";
|
||||
ASSERT_TRUE(str1.contains(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, contains_chars_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s[] = "out";
|
||||
ASSERT_FALSE(str1.contains(s));
|
||||
}
|
||||
|
||||
|
||||
TEST(PIString_Tests, contains_pistring){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString s = "univer";
|
||||
ASSERT_TRUE(str1.contains(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, contains_pistring_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString s = "new";
|
||||
ASSERT_FALSE(str1.contains(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_char){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'i';
|
||||
ASSERT_EQ(6, str1.find(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_char_start){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'i';
|
||||
ASSERT_EQ(18, str1.find(s, 7));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_char_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'o';
|
||||
ASSERT_EQ(-1, str1.find(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_chars){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char str2[] = "is";
|
||||
ASSERT_EQ(6, str1.find(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_chars_start){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char str2[] = "iv";
|
||||
ASSERT_EQ(18, str1.find(str2, 7));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_chars_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s[] = "ouc";
|
||||
ASSERT_EQ(-1, str1.find(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_pistring){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "is";
|
||||
ASSERT_EQ(6, str1.find(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_pistring_start){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "iv";
|
||||
ASSERT_EQ(18, str1.find(str2, 7));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_pistring_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "ouc";
|
||||
ASSERT_EQ(-1, str1.find(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_char){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'i';
|
||||
ASSERT_EQ(27, str1.findLast(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_char_start){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'i';
|
||||
ASSERT_EQ(27, str1.findLast(s, 20));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_char_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'o';
|
||||
ASSERT_EQ(-1, str1.findLast(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_chars){
|
||||
PIString str1 = "BMSTU is (best) university in is space\n";
|
||||
char str2[] = "is";
|
||||
ASSERT_EQ(30, str1.findLast(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_chars_start){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
char str2[] = "iv";
|
||||
ASSERT_EQ(30, str1.findLast(str2, 25));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_chars_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char str2[] = "ouc";
|
||||
ASSERT_EQ(-1, str1.findLast(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_pistring){
|
||||
PIString str1 = "BMSTU is (best) university in is space\n";
|
||||
PIString str2 = "is";
|
||||
ASSERT_EQ(30, str1.findLast(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_pistring_start){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "iv";
|
||||
ASSERT_EQ(30, str1.findLast(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_pistring_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "ouc";
|
||||
ASSERT_EQ(-1, str1.findLast(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_word){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(16, str1.findWord(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_word_start){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(16, str1.findWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_word_space_before){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = " university";
|
||||
ASSERT_EQ(-1, str1.findWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_word_space_after){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university ";
|
||||
ASSERT_EQ(-1, str1.findWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_word_digit_before){
|
||||
PIString str1 = "BMSTU is (best) _university_ in iv space\n";
|
||||
PIString str2 = "_university";
|
||||
ASSERT_EQ(-1, str1.findWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_word_digit_after){
|
||||
PIString str1 = "BMSTU is (best) _university_ in iv space\n";
|
||||
PIString str2 = "university_";
|
||||
ASSERT_EQ(-1, str1.findWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_word_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(-1, str1.findWord(str2, 37));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_cword){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(16, str1.findCWord(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_cword_start){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(16, str1.findCWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_cword_space_before){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = " university";
|
||||
ASSERT_EQ(15, str1.findCWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_cword_space_after){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university ";
|
||||
ASSERT_EQ(-1, str1.findCWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_cword_digit_before){
|
||||
PIString str1 = "BMSTU is (best) _university_ in iv space\n";
|
||||
PIString str2 = "_university";
|
||||
ASSERT_EQ(-1, str1.findCWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_cword_digit_after){
|
||||
PIString str1 = "BMSTU is (best) _university_ in iv space\n";
|
||||
PIString str2 = "university_";
|
||||
ASSERT_EQ(-1, str1.findCWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_cword_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(-1, str1.findCWord(str2, 37));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_range){
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIChar start = "v";
|
||||
PIChar end = "g";
|
||||
int *len;
|
||||
ASSERT_EQ(3, str1.findRange(start, end, "n", 1, len));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_range_len){
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIChar start = "v";
|
||||
PIChar end = "g";
|
||||
int *len;
|
||||
str1.findRange(start, end, "n", 1, len);
|
||||
ASSERT_EQ(14, *len);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_range_len_without_shield){
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIChar start = "v";
|
||||
PIChar end = "g";
|
||||
int *len;
|
||||
str1.findRange(start, end, "/", 1, len);
|
||||
ASSERT_EQ(9, *len);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_range_start){
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIChar start = "g";
|
||||
PIChar end = "o";
|
||||
int *len;
|
||||
str1.findRange(start, end, " ", 17, len);
|
||||
ASSERT_EQ(9, *len);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_range_eq){
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIChar start = "v";
|
||||
PIChar end = "v";
|
||||
int *len;
|
||||
str1.findRange(start, end, "n", 1, len);
|
||||
ASSERT_EQ(0, *len);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_range_trim){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIChar start = "A";
|
||||
PIChar end = "v";
|
||||
int *len;
|
||||
ASSERT_EQ(2, str1.findRange(start, end, "n", 0, len));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "doip";
|
||||
ASSERT_EQ(11, str1.findAny(str2, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_not){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "q";
|
||||
ASSERT_EQ(-1, str1.findAny(str2, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_start){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "doip";
|
||||
ASSERT_EQ(15, str1.findAny(str2, 12));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_chars){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "doip";
|
||||
ASSERT_EQ(11, str1.findAny(str2, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_chars_not){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "q";
|
||||
ASSERT_EQ(-1, str1.findAny(str2, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_chars_start){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "doip";
|
||||
ASSERT_EQ(15, str1.findAny(str2, 12));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_last){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "doip";
|
||||
ASSERT_EQ(39, str1.findAnyLast(str2, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_last_not){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "q";
|
||||
ASSERT_EQ(-1, str1.findAnyLast(str2, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_last_start){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "doip";
|
||||
ASSERT_EQ(39, str1.findAnyLast(str2, 12));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_last_chars){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "doip";
|
||||
ASSERT_EQ(39, str1.findAnyLast(str2, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_last_chars_not){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "q";
|
||||
ASSERT_EQ(-1, str1.findAnyLast(str2, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_last_chars_start){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "doip";
|
||||
ASSERT_EQ(39, str1.findAnyLast(str2, 12));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, entries){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIChar c = "A";
|
||||
ASSERT_EQ(1, str1.entries(c));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, entries_char){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char c = 'A';
|
||||
ASSERT_EQ(1, str1.entries(c));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, starts_with){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = " A very";
|
||||
ASSERT_TRUE(str1.startsWith(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, starts_with_false){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = " A veru";
|
||||
ASSERT_FALSE(str1.startsWith(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, ends_with){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = " code";
|
||||
ASSERT_TRUE(str1.endsWith(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, ends_with_false){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "c code";
|
||||
ASSERT_FALSE(str1.endsWith(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, length){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
ASSERT_EQ(41, str1.length());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, is_empty_false){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
ASSERT_FALSE(str1.isEmpty());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, is_empty_true){
|
||||
PIString str1 = "";
|
||||
ASSERT_TRUE(str1.isEmpty());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_bool){
|
||||
PIString str1 = "1";
|
||||
ASSERT_TRUE(str1.toBool());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_bool_yes){
|
||||
PIString str1 = "yes";
|
||||
ASSERT_TRUE(str1.toBool());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_bool_false){
|
||||
PIString str1 = "no";
|
||||
ASSERT_FALSE(str1.toBool());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_bool_false_zero){
|
||||
PIString str1 = "0";
|
||||
ASSERT_FALSE(str1.toBool());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_char){
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
ASSERT_EQ(65, str1.toChar());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_short){
|
||||
PIString str1 = "133";
|
||||
ASSERT_EQ(133, str1.toShort(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_short_0x){
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toShort(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_short_false){
|
||||
PIString str1 = "0x133";
|
||||
bool *ok;
|
||||
str1.toShort(1, ok);
|
||||
ASSERT_FALSE(*ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_short_false_base){
|
||||
PIString str1 = "7";
|
||||
bool *ok;
|
||||
str1.toShort(6, ok);
|
||||
ASSERT_FALSE(*ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_short_neg){
|
||||
PIString str1 = "-7";
|
||||
bool *ok;
|
||||
ASSERT_EQ(-7, str1.toShort(10, ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ushort){
|
||||
PIString str1 = "133.1";
|
||||
ASSERT_EQ(133, str1.toUShort(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ushort_0x){
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toUShort(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ushort_false){
|
||||
PIString str1 = "0x133";
|
||||
bool *ok;
|
||||
str1.toUShort(1, ok);
|
||||
ASSERT_FALSE(*ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ushort_false_base){
|
||||
PIString str1 = "7";
|
||||
bool *ok;
|
||||
str1.toUShort(6, ok);
|
||||
ASSERT_FALSE(*ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ushort_neg){
|
||||
PIString str1 = "-7";
|
||||
bool *ok;
|
||||
ASSERT_EQ(65529, str1.toUShort(10, ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_int){
|
||||
PIString str1 = "133";
|
||||
ASSERT_EQ(133, str1.toInt(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_int_0x){
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toInt(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_int_false){
|
||||
PIString str1 = "0x133";
|
||||
bool *ok;
|
||||
str1.toInt(1, ok);
|
||||
ASSERT_FALSE(*ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_int_false_base){
|
||||
PIString str1 = "7";
|
||||
bool *ok;
|
||||
str1.toInt(6, ok);
|
||||
ASSERT_FALSE(*ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_int_neg){
|
||||
PIString str1 = "-7";
|
||||
bool *ok;
|
||||
ASSERT_EQ(-7, str1.toShort(10, ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_uint){
|
||||
PIString str1 = "133.1";
|
||||
ASSERT_EQ(133, str1.toUInt(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_uint_0x){
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toUInt(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_uint_false){
|
||||
PIString str1 = "0x133";
|
||||
bool *ok;
|
||||
str1.toUInt(1, ok);
|
||||
ASSERT_FALSE(*ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_uint_false_base){
|
||||
PIString str1 = "7";
|
||||
bool *ok;
|
||||
str1.toUInt(6, ok);
|
||||
ASSERT_FALSE(*ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_uint_neg){
|
||||
PIString str1 = "-7";
|
||||
bool *ok;
|
||||
ASSERT_EQ(4294967289, str1.toUInt(10, ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_long){
|
||||
PIString str1 = "133";
|
||||
ASSERT_EQ(133, str1.toLong(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_long_0x){
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toLong(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_long_false){
|
||||
PIString str1 = "0x133";
|
||||
bool *ok;
|
||||
str1.toLong(1, ok);
|
||||
ASSERT_FALSE(*ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_long_false_base){
|
||||
PIString str1 = "7";
|
||||
bool *ok;
|
||||
str1.toLong(6, ok);
|
||||
ASSERT_FALSE(*ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_long_neg){
|
||||
PIString str1 = "-7";
|
||||
bool *ok;
|
||||
ASSERT_EQ(-7, str1.toLong(10, ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ulong){
|
||||
PIString str1 = "133.1";
|
||||
ASSERT_EQ(133, str1.toULong(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ulong_0x){
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toULong(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ulong_false){
|
||||
PIString str1 = "0x133";
|
||||
bool *ok;
|
||||
str1.toULong(1, ok);
|
||||
ASSERT_FALSE(*ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ulong_false_base){
|
||||
PIString str1 = "7";
|
||||
bool *ok;
|
||||
str1.toULong(6, ok);
|
||||
ASSERT_FALSE(*ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ulong_neg){
|
||||
PIString str1 = "-7";
|
||||
bool *ok;
|
||||
ASSERT_EQ(4294967289, str1.toULong(10, ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_llong){
|
||||
PIString str1 = "133";
|
||||
ASSERT_EQ(133, str1.toLLong(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_llong_0x){
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toLLong(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_llong_false){
|
||||
PIString str1 = "0x133";
|
||||
bool *ok;
|
||||
str1.toLLong(1, ok);
|
||||
ASSERT_FALSE(*ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_llong_false_base){
|
||||
PIString str1 = "7";
|
||||
bool *ok;
|
||||
str1.toLLong(6, ok);
|
||||
ASSERT_FALSE(*ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_llong_neg){
|
||||
PIString str1 = "-7";
|
||||
bool *ok;
|
||||
ASSERT_EQ(-7, str1.toLLong(10, ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ullong){
|
||||
PIString str1 = "133.1";
|
||||
ASSERT_EQ(133, str1.toULLong(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ullong_0x){
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toULLong(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ullong_false){
|
||||
PIString str1 = "0x133";
|
||||
bool *ok;
|
||||
str1.toULLong(1, ok);
|
||||
ASSERT_FALSE(*ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ullong_false_base){
|
||||
PIString str1 = "7";
|
||||
bool *ok;
|
||||
str1.toULLong(6, ok);
|
||||
ASSERT_FALSE(*ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ullong_neg){
|
||||
PIString str1 = "-7";
|
||||
bool *ok;
|
||||
ullong f = 184467451609;
|
||||
ASSERT_EQ(f, str1.toULLong(10, ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_float){
|
||||
PIString str1 = "-7765,54";
|
||||
float f = -7765.54;
|
||||
ASSERT_EQ(f, str1.toFloat());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_double){
|
||||
PIString str1 = "-7765,54656";
|
||||
double f = -7765.54656;
|
||||
ASSERT_EQ(f, str1.toDouble());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ldouble){
|
||||
PIString str1 = "-7765,54656";
|
||||
ldouble f = -7765.54656;
|
||||
ASSERT_EQ(f, str1.toLDouble());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber){
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_STREQ("131", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_zero){
|
||||
PIString str1 = " String";
|
||||
const short val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_STREQ("0", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_false_base){
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_true){
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_STREQ("", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_base_minus){
|
||||
PIString str1 = " String";
|
||||
const short val = -10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
ASSERT_STREQ("-A", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ushort){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_STREQ("131", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ushort_true){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ushort_zero){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_STREQ("0", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ushort_false_base){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ushort_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_STREQ("", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ushort_base_minus){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
ASSERT_STREQ("A", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_int){
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_STREQ("131", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_int_zero){
|
||||
PIString str1 = " String";
|
||||
const int val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_STREQ("0", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_int_false_base){
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_int_true){
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_int_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_STREQ("", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_int_base_minus){
|
||||
PIString str1 = " String";
|
||||
const int val = -10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
ASSERT_STREQ("-A", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_uint){
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_STREQ("131", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_uint_true){
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_uintt_zero){
|
||||
PIString str1 = " String";
|
||||
const uint val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_STREQ("0", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_uint_false_base){
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_uint_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_STREQ("", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_uint_base_minus){
|
||||
PIString str1 = " String";
|
||||
const uint val = 10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
ASSERT_STREQ("A", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_long){
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_STREQ("131", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_long_zero){
|
||||
PIString str1 = " String";
|
||||
const long val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_STREQ("0", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_long_false_base){
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_long_true){
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_long_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_STREQ("", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_long_base_minus){
|
||||
PIString str1 = " String";
|
||||
const long val = -10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
ASSERT_STREQ("-A", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ulong){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_STREQ("131", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ulong_true){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ulong_zero){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_STREQ("0", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ulong_false_base){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ulong_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_STREQ("", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ulong_base_minus){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
ASSERT_STREQ("A", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_llong){
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_STREQ("131", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_llong_zero){
|
||||
PIString str1 = " String";
|
||||
const llong val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_STREQ("0", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_llong_false_base){
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_llong_true){
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_llong_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_STREQ("", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_llong_base_minus){
|
||||
PIString str1 = " String";
|
||||
const llong val = -10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
ASSERT_STREQ("-A", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ullong){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_STREQ("131", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ullong_true){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ullong_zero){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_STREQ("0", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ullong_false_base){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ullong_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_STREQ("", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ullong_base_minus){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
ASSERT_STREQ("A", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_float){
|
||||
PIString str1 = " String";
|
||||
const float val = 131.132;
|
||||
str1.setNumber(val, 'f', 3);
|
||||
ASSERT_STREQ("131.132", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_double){
|
||||
PIString str1 = " String";
|
||||
const double val = 131.1324334;
|
||||
str1.setNumber(val, 'f', 7);
|
||||
ASSERT_STREQ("131.1324334", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ldouble){
|
||||
PIString str1 = " String";
|
||||
const ldouble val = 131.1324334;
|
||||
str1.setNumber(val, 'f', 7);
|
||||
ASSERT_STREQ("131.1324334", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setReadableSize){
|
||||
PIString str1 = " ITELMA";
|
||||
ASSERT_STREQ("1023 B", str1.setReadableSize(1023));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setReadableSize_kb){
|
||||
PIString str1 = " ITELMA";
|
||||
ASSERT_STREQ("1.0 kB", str1.setReadableSize(1024));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setReadableSize_mb){
|
||||
PIString str1 = " ITELMA";
|
||||
ASSERT_STREQ("1.0 MB", str1.setReadableSize(1024*1024));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setReadableSize_gb){
|
||||
PIString str1 = " ITELMA";
|
||||
ASSERT_STREQ("1.0 GB", str1.setReadableSize(1024*1024*1024));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setReadableSize_tb){
|
||||
PIString str1 = " ITELMA";
|
||||
llong val = 99999999999999;
|
||||
ASSERT_STREQ("90.9 TB", str1.setReadableSize(val));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setReadableSize_pb){
|
||||
PIString str1 = " ITELMA";
|
||||
llong val = 999999999999999999;
|
||||
ASSERT_STREQ("888.1 PB", str1.setReadableSize(val));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber){
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
ASSERT_STREQ("131", str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumberr_zero){
|
||||
PIString str1 = " String";
|
||||
const short val = 0;
|
||||
bool ok;
|
||||
ASSERT_STREQ("0", str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_false_base){
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_true){
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
ASSERT_STREQ("", str1.fromNumber(val, 1, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_base_minus){
|
||||
PIString str1 = " String";
|
||||
const short val = -10;
|
||||
bool ok;
|
||||
ASSERT_STREQ("-A", str1.fromNumber(val, 16, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ushort){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
ASSERT_STREQ("131", str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ushort_true){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ushort_zero){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 0;
|
||||
bool ok;
|
||||
ASSERT_STREQ("0", str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ushort_false_base){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ushort_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
ASSERT_STREQ("", str1.fromNumber(val, 1, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ushort_base_minus){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 10;
|
||||
bool ok;
|
||||
ASSERT_STREQ("A", str1.fromNumber(val, 16, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_int){
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
ASSERT_STREQ("131", str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_int_zero){
|
||||
PIString str1 = " String";
|
||||
const int val = 0;
|
||||
bool ok;
|
||||
ASSERT_STREQ("0", str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_int_false_base){
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_int_true){
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_int_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
ASSERT_STREQ("", str1.fromNumber(val, 1, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_int_base_minus){
|
||||
PIString str1 = " String";
|
||||
const int val = -10;
|
||||
bool ok;
|
||||
ASSERT_STREQ("-A", str1.fromNumber(val, 16, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_uint){
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
ASSERT_STREQ("131", str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_uint_true){
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_uintt_zero){
|
||||
PIString str1 = " String";
|
||||
const uint val = 0;
|
||||
bool ok;
|
||||
ASSERT_STREQ("0", str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_uint_false_base){
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_uint_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
ASSERT_STREQ("", str1.fromNumber(val, 1, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_uint_base_minus){
|
||||
PIString str1 = " String";
|
||||
const uint val = 10;
|
||||
bool ok;
|
||||
ASSERT_STREQ("A", str1.fromNumber(val, 16, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_long){
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
ASSERT_STREQ("131", str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_long_zero){
|
||||
PIString str1 = " String";
|
||||
const long val = 0;
|
||||
bool ok;
|
||||
ASSERT_STREQ("0", str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_long_false_base){
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_long_true){
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_long_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
ASSERT_STREQ("", str1.fromNumber(val, 1, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_long_base_minus){
|
||||
PIString str1 = " String";
|
||||
const long val = -10;
|
||||
bool ok;
|
||||
ASSERT_STREQ("-A", str1.fromNumber(val, 16, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ulong){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
ASSERT_STREQ("131", str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ulong_true){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ulong_zero){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 0;
|
||||
bool ok;
|
||||
ASSERT_STREQ("0", str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ulong_false_base){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ulong_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
ASSERT_STREQ("", str1.fromNumber(val, 1, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ulong_base_minus){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 10;
|
||||
bool ok;
|
||||
ASSERT_STREQ("A", str1.fromNumber(val, 16, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_llong){
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
ASSERT_STREQ("131", str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_llong_zero){
|
||||
PIString str1 = " String";
|
||||
const llong val = 0;
|
||||
bool ok;
|
||||
ASSERT_STREQ("0", str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_llong_false_base){
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_llong_true){
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_llong_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
ASSERT_STREQ("", str1.fromNumber(val, 1, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_llong_base_minus){
|
||||
PIString str1 = " String";
|
||||
const llong val = -10;
|
||||
bool ok;
|
||||
ASSERT_STREQ("-A", str1.fromNumber(val, 16, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ullong){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
ASSERT_STREQ("131", str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ullong_true){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ullong_zero){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 0;
|
||||
bool ok;
|
||||
ASSERT_STREQ("0", str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ullong_false_base){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ullong_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
ASSERT_STREQ("", str1.fromNumber(val, 1, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ullong_base_minus){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 10;
|
||||
bool ok;
|
||||
ASSERT_STREQ("A", str1.fromNumber(val, 16, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_float){
|
||||
PIString str1 = " String";
|
||||
const float val = 131.132;
|
||||
ASSERT_STREQ("131.132", str1.fromNumber(val, 'f', 3));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_double){
|
||||
PIString str1 = " String";
|
||||
const double val = 131.1324334;
|
||||
ASSERT_STREQ("131.1324334", str1.fromNumber(val, 'f', 7));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ldouble){
|
||||
PIString str1 = " String";
|
||||
const ldouble val = 131.1324334;
|
||||
ASSERT_STREQ("131.1324334", str1.fromNumber(val, 'f', 7));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromBool_true){
|
||||
PIString str1;
|
||||
bool val = true;
|
||||
ASSERT_STREQ("true", str1.fromBool(val));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromBool_false){
|
||||
PIString str1;
|
||||
bool val = false;
|
||||
ASSERT_STREQ("false", str1.fromBool(val));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, from_Console){
|
||||
PIString str1;
|
||||
char s[] = "true boy";
|
||||
ASSERT_STREQ("true boy", str1.fromConsole(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, from_System){
|
||||
PIString str1;
|
||||
char s[] = "true boy";
|
||||
ASSERT_STREQ("true boy", str1.fromSystem(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, from_UTF8){
|
||||
PIString str1;
|
||||
char s[] = "true boy";
|
||||
ASSERT_STREQ("true boy", str1.fromUTF8(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, from_UTF8_ba){
|
||||
PIString str1;
|
||||
PIByteArray s;
|
||||
s.append('t');
|
||||
s.append('r');
|
||||
s.append('u');
|
||||
s.append('e');
|
||||
ASSERT_STREQ("true", str1.fromUTF8(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, from_Ascii){
|
||||
PIString str1;
|
||||
char s[] = "true boy";
|
||||
ASSERT_STREQ("true boy", str1.fromAscii(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, from_Codepage){
|
||||
PIString str1 = "Nul";
|
||||
char s[] = "true";
|
||||
char c[] = "utf8";
|
||||
PIString str2 = str1.fromCodepage(s, c);
|
||||
ASSERT_STREQ("true", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, ReadableSize){
|
||||
PIString str1 = " ITELMA";
|
||||
ASSERT_STREQ("1023 B", str1.readableSize(1023));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, readableSize_kb){
|
||||
PIString str1 = " ITELMA";
|
||||
ASSERT_STREQ("1.0 kB", str1.readableSize(1024));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, readableSize_mb){
|
||||
PIString str1 = " ITELMA";
|
||||
ASSERT_STREQ("1.0 MB", str1.readableSize(1024*1024));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, readableSize_gb){
|
||||
PIString str1 = " ITELMA";
|
||||
ASSERT_STREQ("1.0 GB", str1.readableSize(1024*1024*1024));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, readableSize_tb){
|
||||
PIString str1 = " ITELMA";
|
||||
llong val = 99999999999999;
|
||||
ASSERT_STREQ("90.9 TB", str1.readableSize(val));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, readableSize_pb){
|
||||
PIString str1 = " ITELMA";
|
||||
llong val = 999999999999999999;
|
||||
ASSERT_STREQ("888.1 PB", str1.readableSize(val));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, removeAll_char){
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
char v = ' ';
|
||||
ASSERT_STREQ("Averystrongprogrammerwrotethiscode", str1.removeAll(v));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, removeAll_pistring){
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIString v = "very strong ";
|
||||
ASSERT_STREQ("A programmer wrote this code", str1.removeAll(v));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_ba_pstr){
|
||||
PIString str1 = '1';
|
||||
PIByteArray s;
|
||||
s << str1;
|
||||
ASSERT_STREQ("010000003100", s.toHex());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_pstr_ba){
|
||||
PIString str1 = "1";
|
||||
PIByteArray s;
|
||||
s.append('t');
|
||||
s.append('r');
|
||||
s.append('u');
|
||||
s.append('e');
|
||||
str1 << s;
|
||||
ASSERT_STREQ("1true", str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_plus_pstr_pstr){
|
||||
PIString str1 = "first ";
|
||||
PIString str2 = "second";
|
||||
ASSERT_STREQ("first second", str1 + str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_plus_pstr_chars){
|
||||
PIString str1 = "first ";
|
||||
char str2[] = "second";
|
||||
ASSERT_STREQ("first second", str1 + str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_plus_chars_pstr){
|
||||
PIString str1 = "first";
|
||||
char str2[] = "second ";
|
||||
ASSERT_STREQ("second first", str2 + str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, versionCompare2){ //дописать
|
||||
PIString str1 = "first";
|
||||
PIString str2 = "first 1";
|
||||
versionCompare(str1, str2, 0);
|
||||
ASSERT_EQ(898448032, piHash(str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, versionNormalize2){ //дописать
|
||||
PIString str1 = "first";
|
||||
cout << versionNormalize(str1);
|
||||
ASSERT_EQ(1, 1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, piHash){
|
||||
PIString str1 = "first";
|
||||
ASSERT_EQ(898448032, piHash(str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, piSwap){
|
||||
PIString str1 = "first";
|
||||
PIString str2 = "second";
|
||||
piSwap(str1, str2);
|
||||
ASSERT_STREQ("first", str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, piSwap_sec){
|
||||
PIString str1 = "first";
|
||||
PIString str2 = "second";
|
||||
piSwap(str1, str2);
|
||||
ASSERT_STREQ("second", str1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ set(PIP_UTILS_LIST ${PIP_UTILS_LIST} PARENT_SCOPE)
|
||||
import_version(pip_cmg pip)
|
||||
set_deploy_property(pip_cmg
|
||||
LABEL "PIP code model generator"
|
||||
FULLNAME "${_PIP_DOMAIN}.pip_cmg"
|
||||
COMPANY "${_PIP_COMPANY}"
|
||||
FULLNAME "${pip_DOMAIN}.pip_cmg"
|
||||
COMPANY "${pip_COMPANY}"
|
||||
INFO "Platform-Independent Primitives")
|
||||
make_rc(pip_cmg _RC)
|
||||
add_executable(pip_cmg "main.cpp" ${_RC})
|
||||
|
||||
@@ -3,8 +3,8 @@ set(PIP_UTILS_LIST ${PIP_UTILS_LIST} PARENT_SCOPE)
|
||||
import_version(deploy_tool pip)
|
||||
set_deploy_property(deploy_tool
|
||||
LABEL "PIP deploy tool"
|
||||
FULLNAME "${_PIP_DOMAIN}.deploy_tool"
|
||||
COMPANY "${_PIP_COMPANY}"
|
||||
FULLNAME "${pip_DOMAIN}.deploy_tool"
|
||||
COMPANY "${pip_COMPANY}"
|
||||
INFO "Platform-Independent Primitives")
|
||||
make_rc(deploy_tool _RC)
|
||||
file(GLOB SRC "*.cpp" "*.h")
|
||||
|
||||
@@ -84,6 +84,7 @@ void usage() {
|
||||
piCout << "-D <dpkg> " << Green << "- \"dpkg\" path, default \"/usr/bin/dpkg\"";
|
||||
piCout << "--dpkg-workdir <d> " << Green << "- dpkg \"admindir\" path, default \"\"";
|
||||
piCout << "--name-tool <path> " << Green << "- \"install_name_tool\" path, default \"install_name_tool\"";
|
||||
piCout << "--strip <path> " << Green << "- \"strip\" path, default \"strip\"";
|
||||
piCout << "-d <depth> " << Green << "- maximum dependepcies depth, default 8";
|
||||
piCout << "";
|
||||
piCout << Bold << "Qt control";
|
||||
@@ -127,7 +128,7 @@ QtDep qt_deps[] = {
|
||||
|
||||
int depth = 8;
|
||||
bool fake = false, is_ldd = true, is_deps = false, need_qt = false;
|
||||
PIString ldd, readelf, objdump, otool, dpkg, nametool, out_dir, qt_dir, out_plugins_dir, dpkg_workdir;
|
||||
PIString ldd, readelf, objdump, otool, dpkg, nametool, strip, out_dir, qt_dir, out_plugins_dir, dpkg_workdir;
|
||||
PIStringList styles, lib_dirs, add_libs, platforms, sqldrivers, input_files, plugin_libs;
|
||||
PISet<PIString> all_libs, miss_libs, all_deps, frameworks, framework_libs, miss_frameworks, qt_plugins, ignore_libs;
|
||||
PIMap<PIString, PIStringList> qt_filters;
|
||||
@@ -488,6 +489,7 @@ int main(int argc, char * argv[]) {
|
||||
cli.addArgument("Wobjdump", true);
|
||||
cli.addArgument("Motool", true);
|
||||
cli.addArgument("name-tool", PIChar('\0'), true);
|
||||
cli.addArgument("strip", PIChar('\0'), true);
|
||||
cli.addArgument("Dpkg", true);
|
||||
cli.addArgument("dpkg-workdir", PIChar('\0'), true);
|
||||
cli.addArgument("depth", true);
|
||||
@@ -512,8 +514,11 @@ int main(int argc, char * argv[]) {
|
||||
objdump = cli.argumentValue("Wobjdump");
|
||||
otool = cli.argumentValue("Motool");
|
||||
nametool = cli.argumentValue("name-tool");
|
||||
strip = cli.argumentValue("strip");
|
||||
if (nametool.isEmpty())
|
||||
nametool = "install_name_tool";
|
||||
if (strip.isEmpty())
|
||||
strip = "strip";
|
||||
dpkg = cli.argumentValue("Dpkg");
|
||||
dpkg_workdir = cli.argumentValue("dpkg-workdir");
|
||||
#ifdef WINDOWS
|
||||
@@ -628,6 +633,8 @@ int main(int argc, char * argv[]) {
|
||||
#endif
|
||||
PIVector<PIString> clibs = all_libs.toVector();
|
||||
piForeach (PIString l, clibs) {
|
||||
PIFile::FileInfo fi;
|
||||
fi.path = l;
|
||||
#ifdef WINDOWS
|
||||
l.replaceAll("/", "\\");
|
||||
#endif
|
||||
@@ -636,8 +643,10 @@ int main(int argc, char * argv[]) {
|
||||
need_cp = !procDpkg(l);
|
||||
if (need_cp) {
|
||||
piCout << "copy" << l;
|
||||
if (!fake)
|
||||
if (!fake) {
|
||||
system(cmd_copy + "\"" + l + "\" \"" + out_dir + "\"" + cmd_suffix);
|
||||
system(strip + " --strip-unneeded \"" + out_dir + fi.name() + "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
PIVector<PIString> fwdirs = frameworks.toVector();
|
||||
|
||||
@@ -3,8 +3,8 @@ set(PIP_UTILS_LIST ${PIP_UTILS_LIST} PARENT_SCOPE)
|
||||
import_version(pip_rc pip)
|
||||
set_deploy_property(pip_rc
|
||||
LABEL "PIP resources compiler"
|
||||
FULLNAME "${_PIP_DOMAIN}.pip_rc"
|
||||
COMPANY "${_PIP_COMPANY}"
|
||||
FULLNAME "${pip_DOMAIN}.pip_rc"
|
||||
COMPANY "${pip_COMPANY}"
|
||||
INFO "Platform-Independent Primitives")
|
||||
make_rc(pip_rc _RC)
|
||||
file(GLOB SRC "*.cpp" "*.h")
|
||||
|
||||
Reference in New Issue
Block a user