diff --git a/SConstruct b/SConstruct index ef08067384..ed62906a64 100644 --- a/SConstruct +++ b/SConstruct @@ -46,7 +46,7 @@ DEBUGFLAGS = ['-g', '-DDEBUG'] env.Append(LINKFLAGS = ['-rdynamic', '-pthread']) env.Append(CCFLAGS = ['-pthread', '-Wall', '-Wno-sign-compare', '-Wno-char-subscripts', '-DSQLITE_THREADSAFE']) -env.Append(CXXFLAGS = ['-O0', '-pthread', '-Wno-invalid-offsetof', '-Wformat']+DEBUGFLAGS) +env.Append(CXXFLAGS = ['-O0', '-pthread', '-Wno-invalid-offsetof', '-Wformat', '-DBOOST_TEST_DYN_LINK ']+DEBUGFLAGS) DB_SRCS = glob.glob('database/*.c') + glob.glob('database/*.cpp') JSON_SRCS = glob.glob('json/*.cpp') diff --git a/src/NewcoinAddress.cpp b/src/NewcoinAddress.cpp index e07a7d3342..185943ddda 100644 --- a/src/NewcoinAddress.cpp +++ b/src/NewcoinAddress.cpp @@ -11,6 +11,7 @@ #include #include #include +#include NewcoinAddress::NewcoinAddress() { @@ -506,4 +507,13 @@ void NewcoinAddress::setFamilySeedRandom() NewcoinAddress::setFamilySeed(key); } + +BOOST_AUTO_TEST_SUITE(newcoin_address) + +BOOST_AUTO_TEST_CASE( my_test ) +{ + BOOST_CHECK( false ); +} + +BOOST_AUTO_TEST_SUITE_END() // vim:ts=4 diff --git a/src/NewcoinAddress.h b/src/NewcoinAddress.h index 3621c19efb..21f7729274 100644 --- a/src/NewcoinAddress.h +++ b/src/NewcoinAddress.h @@ -11,14 +11,14 @@ class NewcoinAddress : public CBase58Data { private: typedef enum { - VER_NONE = 1, - VER_NODE_PUBLIC = 28, + VER_NONE = 1, + VER_NODE_PUBLIC = 28, VER_NODE_PRIVATE = 32, - VER_ACCOUNT_ID = 0, + VER_ACCOUNT_ID = 0, VER_ACCOUNT_PUBLIC = 35, VER_ACCOUNT_PRIVATE = 34, VER_FAMILY_GENERATOR = 41, - VER_FAMILY_SEED = 33, + VER_FAMILY_SEED = 33, } VersionEncoding; void seedInfo(NewcoinAddress* dstGenerator, BIGNUM** dstPrivateKey) const; @@ -88,6 +88,7 @@ public: // // Family Generators + // Use to generate a master or regular family. // BIGNUM* getFamilyGeneratorBN() const; const std::vector& getFamilyGenerator() const; @@ -114,3 +115,4 @@ public: }; #endif +// vim:ts=4 diff --git a/src/main.cpp b/src/main.cpp index c8dceb02d7..b90c823ee8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,11 +7,13 @@ #include #include +#include + namespace po = boost::program_options; extern bool AddSystemEntropy(); using namespace std; -using namespace boost; +using namespace boost::unit_test; void startServer() { @@ -19,6 +21,14 @@ void startServer() theApp->run(); // Blocks till we get a stop RPC. } + +bool init_unit_test() +{ + nothing(); + + return true; +} + void printHelp(const po::options_description& desc) { cout << "newcoin [options] " << endl; @@ -56,11 +66,14 @@ int main(int argc, char* argv[]) po::options_description desc("Options"); desc.add_options() ("help,h", "Display this message.") - ("command", po::value< vector >(), "Specify a comma seperated RPC command.") + ("rpc", "Perform rpc command (default).") + ("test,t", "Perform unit tests.") + ("parameters", po::value< vector >(), "Specify comma seperated parameters.") ; + // Interpert positional arguments as --parameters. po::positional_options_description p; - p.add("command", -1); + p.add("parameters", -1); // // Prepare to run @@ -78,7 +91,7 @@ int main(int argc, char* argv[]) { po::store(po::command_line_parser(argc, argv) .options(desc) // Parse options. - .positional(p) // Remainder as --command. + .positional(p) // Remainder as --parameters. .run(), vm); po::notify(vm); // Invoke option notify functions. @@ -92,7 +105,22 @@ int main(int argc, char* argv[]) { iResult = 1; } - else if (!vm.count("command")) + else if (vm.count("test")) + { + std::vector vCmd; + int iCmd = vm.count("parameters"); + + if (iCmd) + vCmd = vm["parameters"].as >(); + + char* pvCmd[iCmd]; + + for (int i=0; i != iCmd; ++i) + pvCmd[i] = (char*) (vCmd[0].c_str()); + + iResult = unit_test_main(init_unit_test, iCmd, pvCmd); + } + else if (!vm.count("parameters")) { // No arguments. Run server. startServer(); @@ -100,7 +128,7 @@ int main(int argc, char* argv[]) else { // Have a RPC command. - std::vector vCmd = vm["command"].as >(); + std::vector vCmd = vm["parameters"].as >(); iResult = commandLineRPC(vCmd); }