annotate UnitTestsSources/TestCommands.cpp @ 826:2de01660debe

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 29 May 2019 16:48:56 +0200
parents b70e9be013e4
children 069519ae389b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
1 ///**
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
2 // * Stone of Orthanc
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
3 // * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
4 // * Department, University Hospital of Liege, Belgium
439
b70e9be013e4 preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 307
diff changeset
5 // * Copyright (C) 2017-2019 Osimis S.A., Belgium
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
6 // *
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
7 // * This program is free software: you can redistribute it and/or
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
8 // * modify it under the terms of the GNU Affero General Public License
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
9 // * as published by the Free Software Foundation, either version 3 of
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
10 // * the License, or (at your option) any later version.
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
11 // *
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
12 // * This program is distributed in the hope that it will be useful, but
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
13 // * WITHOUT ANY WARRANTY; without even the implied warranty of
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
14 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
15 // * Affero General Public License for more details.
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
16 // *
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
17 // * You should have received a copy of the GNU Affero General Public License
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
18 // * along with this program. If not, see <http://www.gnu.org/licenses/>.
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
19 // **/
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
20
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
21
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
22 //#include "gtest/gtest.h"
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
23
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
24 //#include "../Applications/Commands/BaseCommandFactory.h"
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
25 //#include "Core/OrthancException.h"
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
26
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
27 //class CommandIncrement: public OrthancStone::BaseCommand<CommandIncrement>
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
28 //{
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
29 //public:
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
30 // static int counter;
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
31 // int increment_;
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
32 //public:
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
33 // CommandIncrement()
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
34 // : OrthancStone::BaseCommand<CommandIncrement>("increment"),
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
35 // increment_(0)
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
36 // {}
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
37
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
38 // virtual void Execute()
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
39 // {
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
40 // counter += increment_;
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
41 // }
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
42 // virtual void Configure(const Json::Value& arguments)
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
43 // {
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
44 // increment_ = arguments["increment"].asInt();
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
45 // }
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
46 //};
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
47
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
48 //// COMMAND("name", "arg1", "int", "arg2", "string")
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
49 //// COMMAND(name, arg1, arg2)
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
50
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
51
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
52 //int CommandIncrement::counter = 0;
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
53
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
54 //TEST(Commands, CreateNoop)
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
55 //{
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
56 // OrthancStone::BaseCommandFactory factory;
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
57
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
58 // factory.RegisterCommandClass<OrthancStone::NoopCommand>();
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
59
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
60 // Json::Value cmdJson;
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
61 // cmdJson["command"] = "noop";
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
62
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
63 // std::auto_ptr<OrthancStone::ICommand> command(factory.CreateFromJson(cmdJson));
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
64
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
65 // ASSERT_TRUE(command.get() != NULL);
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
66 // ASSERT_EQ("noop", command->GetName());
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
67 //}
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
68
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
69 //TEST(Commands, Execute)
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
70 //{
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
71 // OrthancStone::BaseCommandFactory factory;
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
72
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
73 // factory.RegisterCommandClass<OrthancStone::NoopCommand>();
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
74 // factory.RegisterCommandClass<CommandIncrement>();
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
75
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
76 // Json::Value cmdJson;
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
77 // cmdJson["command"] = "increment";
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
78 // cmdJson["args"]["increment"] = 2;
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
79
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
80 // std::auto_ptr<OrthancStone::ICommand> command(factory.CreateFromJson(cmdJson));
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
81
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
82 // ASSERT_TRUE(command.get() != NULL);
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
83 // CommandIncrement::counter = 0;
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
84 // command->Execute();
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
85 // ASSERT_EQ(2, CommandIncrement::counter);
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
86 //}
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
87
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
88 //TEST(Commands, TryCreateUnknowCommand)
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
89 //{
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
90 // OrthancStone::BaseCommandFactory factory;
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
91 // factory.RegisterCommandClass<OrthancStone::NoopCommand>();
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
92
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
93 // Json::Value cmdJson;
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
94 // cmdJson["command"] = "unknown";
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
95
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
96 // ASSERT_THROW(std::auto_ptr<OrthancStone::ICommand> command(factory.CreateFromJson(cmdJson)), Orthanc::OrthancException);
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
97 //}
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
98
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
99 //TEST(Commands, TryCreateCommandFromInvalidJson)
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
100 //{
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
101 // OrthancStone::BaseCommandFactory factory;
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
102 // factory.RegisterCommandClass<OrthancStone::NoopCommand>();
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
103
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
104 // Json::Value cmdJson;
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
105 // cmdJson["command-name"] = "noop";
295
b04b13810540 unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff changeset
106
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
107 // ASSERT_THROW(std::auto_ptr<OrthancStone::ICommand> command(factory.CreateFromJson(cmdJson)), Orthanc::OrthancException);
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 295
diff changeset
108 //}