diff options
Diffstat (limited to 'cpp/test/Freeze/complex')
-rw-r--r-- | cpp/test/Freeze/complex/Client.cpp | 126 | ||||
-rw-r--r-- | cpp/test/Freeze/complex/NodeI.h | 48 | ||||
-rw-r--r-- | cpp/test/Freeze/complex/Parser.cpp | 14 |
3 files changed, 94 insertions, 94 deletions
diff --git a/cpp/test/Freeze/complex/Client.cpp b/cpp/test/Freeze/complex/Client.cpp index 7012c50f038..fdc3850b8a9 100644 --- a/cpp/test/Freeze/complex/Client.cpp +++ b/cpp/test/Freeze/complex/Client.cpp @@ -32,22 +32,22 @@ validate(const Complex::ComplexDict& m) Parser myParser; for(p = m.begin(); p != m.end(); ++p) { - // - // Verify the stored record is correct. - // + // + // Verify the stored record is correct. + // // COMPILERFIX: VC.NET reports an unhandled // exception if the test is written this way: // - //test(p->first.result == p->second->calc()); + //test(p->first.result == p->second->calc()); // Complex::NodePtr n = p->second; - test(p->first.result == n->calc()); + test(p->first.result == n->calc()); - // - // Verify that the expression & result again. - // - Complex::NodePtr root = myParser.parse(p->first.expression); - test(root->calc() == p->first.result); + // + // Verify that the expression & result again. + // + Complex::NodePtr root = myParser.parse(p->first.expression); + test(root->calc() == p->first.result); } cout << "ok" << endl; @@ -71,12 +71,12 @@ populate(Complex::ComplexDict& m) Parser myParser; for(size_t i = 0 ; i < nexpressions; ++i) { - Complex::NodePtr root = myParser.parse(expressions[i]); - assert(root); - Complex::Key k; - k.expression = expressions[i]; - k.result = root->calc(); - m.put(pair<const Complex::Key, const Complex::NodePtr>(k, root)); + Complex::NodePtr root = myParser.parse(expressions[i]); + assert(root); + Complex::Key k; + k.expression = expressions[i]; + k.result = root->calc(); + m.put(pair<const Complex::Key, const Complex::NodePtr>(k, root)); } cout << "ok" << endl; @@ -87,8 +87,8 @@ static void usage(const char* name) { cerr << "Usage: " << name << " [options] validate|populate\n"; - cerr << - "Options:\n" + cerr << + "Options:\n" "--dbdir Location of the database directory.\n"; } @@ -105,11 +105,11 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator, Complex::C if(argc > 1 && strcmp(argv[1], "populate") == 0) { - return populate(m); + return populate(m); } if(argc > 1 && strcmp(argv[1], "validate") == 0) { - return validate(m); + return validate(m); } usage(argv[0]); @@ -126,59 +126,59 @@ main(int argc, char* argv[]) try { - // - // Scan for --dbdir command line argument. - // - int i = 1; - while(i < argc) - { - if(strcmp(argv[i], "--dbdir") == 0) - { - if(i +1 >= argc) - { - usage(argv[0]); - return EXIT_FAILURE; - } - - envName = argv[i+1]; - envName += "/"; - envName += "db"; - - // - // Consume arguments - // - while(i < argc - 2) - { - argv[i] = argv[i+2]; - ++i; - } - argc -= 2; - } - else - { - ++i; - } - } - - communicator = Ice::initialize(argc, argv); - Freeze::ConnectionPtr connection = createConnection(communicator, envName); - Complex::ComplexDict m(connection, "test"); - status = run(argc, argv, communicator, m); + // + // Scan for --dbdir command line argument. + // + int i = 1; + while(i < argc) + { + if(strcmp(argv[i], "--dbdir") == 0) + { + if(i +1 >= argc) + { + usage(argv[0]); + return EXIT_FAILURE; + } + + envName = argv[i+1]; + envName += "/"; + envName += "db"; + + // + // Consume arguments + // + while(i < argc - 2) + { + argv[i] = argv[i+2]; + ++i; + } + argc -= 2; + } + else + { + ++i; + } + } + + communicator = Ice::initialize(argc, argv); + Freeze::ConnectionPtr connection = createConnection(communicator, envName); + Complex::ComplexDict m(connection, "test"); + status = run(argc, argv, communicator, m); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } try { - communicator->destroy(); + communicator->destroy(); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } return status; diff --git a/cpp/test/Freeze/complex/NodeI.h b/cpp/test/Freeze/complex/NodeI.h index 40479c2e2ba..296b3096260 100644 --- a/cpp/test/Freeze/complex/NodeI.h +++ b/cpp/test/Freeze/complex/NodeI.h @@ -26,12 +26,12 @@ public: NumberNodeI(int n) { - number = n; + number = n; } virtual int calc(const Ice::Current&) { - return number; + return number; } }; @@ -45,13 +45,13 @@ public: AddNodeI(const NodePtr& l, const NodePtr& r) { - left = l; - right = r; + left = l; + right = r; } virtual int calc(const Ice::Current&) { - return left->calc() + right->calc(); + return left->calc() + right->calc(); } }; @@ -65,13 +65,13 @@ public: MultiplyNodeI(const NodePtr& l, const NodePtr& r) { - left = l; - right = r; + left = l; + right = r; } virtual int calc(const Ice::Current&) { - return left->calc() * right->calc(); + return left->calc() * right->calc(); } }; @@ -81,26 +81,26 @@ public: virtual Ice::ObjectPtr create(const std::string& type) { - if(type == "::Complex::MultiplyNode") - { - return new MultiplyNodeI(); - } - if(type == "::Complex::AddNode") - { - return new AddNodeI(); - } - if(type == "::Complex::NumberNode") - { - return new NumberNodeI(); - } - std::cout << "create: " << type << std::endl; - assert(false); - return 0; + if(type == "::Complex::MultiplyNode") + { + return new MultiplyNodeI(); + } + if(type == "::Complex::AddNode") + { + return new AddNodeI(); + } + if(type == "::Complex::NumberNode") + { + return new NumberNodeI(); + } + std::cout << "create: " << type << std::endl; + assert(false); + return 0; } virtual void destroy() { - // Nothing to do + // Nothing to do } }; diff --git a/cpp/test/Freeze/complex/Parser.cpp b/cpp/test/Freeze/complex/Parser.cpp index 96616e9daa1..6114668e970 100644 --- a/cpp/test/Freeze/complex/Parser.cpp +++ b/cpp/test/Freeze/complex/Parser.cpp @@ -45,7 +45,7 @@ Parser::parse(const string& commands, bool debug) if(_errors) { - return 0; + return 0; } return _result; @@ -70,17 +70,17 @@ Parser::getInput(char* buf, int& result, int maxSize) if(!_buf.empty()) { #if defined(_MSC_VER) && !defined(_STLP_MSVC) - // COMPILERBUG: Stupid Visual C++ defines min and max as macros - result = _MIN(maxSize, static_cast<int>(_buf.length())); + // COMPILERBUG: Stupid Visual C++ defines min and max as macros + result = _MIN(maxSize, static_cast<int>(_buf.length())); #else - result = min(maxSize, static_cast<int>(_buf.length())); + result = min(maxSize, static_cast<int>(_buf.length())); #endif - strncpy(buf, _buf.c_str(), result); - _buf.erase(0, result); + strncpy(buf, _buf.c_str(), result); + _buf.erase(0, result); } else { - result = 0; + result = 0; } } |