重组程序
This commit is contained in:
parent
dcff6f7726
commit
88cca192fc
@ -6,11 +6,8 @@ set(CMAKE_CXX_STANDARD 14)
|
||||
include_directories(include/)
|
||||
include_directories(utils/)
|
||||
|
||||
find_package(sqlite3 REQUIRED)
|
||||
find_package(Boost COMPONENTS
|
||||
program_options REQUIRED)
|
||||
find_package(Boost REQUIRED)
|
||||
find_package(SQLiteCpp REQUIRED)
|
||||
find_package(gtest REQUIRED)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
||||
message(STATUS SSL ${OPENSSL_LIBRARIES})
|
||||
@ -26,27 +23,14 @@ link_directories(${GTEST_LIB})
|
||||
|
||||
aux_source_directory(src SOURCE_ALL)
|
||||
|
||||
add_executable(NetTest test/test_main.cpp)
|
||||
|
||||
# add_executable(Net ${SOURCE} src/rsacpp.cpp include/rsacpp.h src/init.cpp include/init.h)
|
||||
add_executable(NetRSATest test/rsa_test.cpp)
|
||||
|
||||
gtest_add_tests(TARGET NetRSATest
|
||||
gtest_add_tests(TARGET NetTest
|
||||
TEST_SUFFIX .noArgs
|
||||
TEST_LIST noArgsTests)
|
||||
|
||||
add_executable(NetOptsPceTest test/opts_processor_test.cpp)
|
||||
|
||||
gtest_add_tests(TARGET NetOptsPceTest
|
||||
TEST_SUFFIX .noArgs
|
||||
TEST_LIST noArgsTests)
|
||||
|
||||
add_library(m_error STATIC src/error.cpp)
|
||||
add_library(m_rsa STATIC src/rsa_cpp_binding.cpp)
|
||||
add_library(test_main STATIC test/test_main.cpp)
|
||||
|
||||
|
||||
|
||||
target_link_libraries(NetRSATest test_main m_rsa m_error ${GTEST_LIBS} ${OPENSSL_LIBS})
|
||||
target_link_libraries(NetOptsPceTest test_main m_error Boost::program_options)
|
||||
set_tests_properties(${noArgsTests} PROPERTIES TIMEOUT 10)
|
||||
# target_link_libraries(Net SQLiteCpp sqlite3 gtest ${Boost_LIBRARIES} pthread dl ssl )
|
||||
target_link_libraries(NetTest m_rsa m_error ${GTEST_LIBS} ssl crypto boost_program_options)
|
||||
set_tests_properties(${noArgsTests} PROPERTIES TIMEOUT 10)
|
@ -13,7 +13,7 @@ namespace po = boost::program_options;
|
||||
|
||||
class OptsProcessor {
|
||||
public:
|
||||
OptsProcessor(){
|
||||
OptsProcessor(int argc, char *argv[]){
|
||||
desc.add_options()
|
||||
("help", "help list")
|
||||
("init", "set up the environment")
|
||||
@ -23,7 +23,7 @@ public:
|
||||
("client", "start a client daemon")
|
||||
("set", "change an option");
|
||||
po::variables_map vm;
|
||||
po::store(po::parse_command_line(ac, av, desc), vm);
|
||||
po::store(po::parse_command_line(argc, argv, desc), vm);
|
||||
po::notify(vm);
|
||||
|
||||
if (vm.count("help")) {
|
||||
@ -40,7 +40,6 @@ public:
|
||||
}
|
||||
private:
|
||||
po::options_description desc("General Net Tools (0.0.1) By Saturn&Eric");
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -6,12 +6,14 @@
|
||||
#define NET_RSA_CPP_BINDING_H
|
||||
|
||||
#include "error.h"
|
||||
#include "bignumber.cpp"
|
||||
#include "../src/bignumber.cpp"
|
||||
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cassert>
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
@ -19,7 +19,6 @@ void Net::RSAKeyChain::generateKeyPair() {
|
||||
void Net::RSAKeyChain::privateKeyDecrypt(string &data, const string &encrypted_data) {
|
||||
if(!this->if_prv_key) throw runtime_error("illegal call of privateKeyDecrypt");
|
||||
if(this->key_pair == nullptr) throw runtime_error("key pair is invalid");
|
||||
assert(buffer_size > 0);
|
||||
if(encrypted_data.size() != buffer_size) throw runtime_error("encrypt data's size is abnormal");
|
||||
// 使用私钥解密
|
||||
int decrypted_size = -1;
|
||||
|
@ -10,7 +10,7 @@
|
||||
using namespace Net;
|
||||
using namespace std;
|
||||
|
||||
GlobalTestEnv *_env;
|
||||
extern GlobalTestEnv *_env;
|
||||
|
||||
TEST(RSATest, init_test_1) {
|
||||
|
||||
|
@ -4,9 +4,11 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "rsa_test.cpp"
|
||||
|
||||
#include "env.h"
|
||||
|
||||
extern GlobalTestEnv *_env;
|
||||
GlobalTestEnv *_env;
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
Loading…
Reference in New Issue
Block a user