Mercurial > hg > orthanc-stone
annotate UnitTestsSources/TestCommands.cpp @ 1442:11f291ac3ef5 legacy-loader-refactoring
This branch is useless.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 26 May 2020 10:11:49 +0200 |
parents | 8a0a62189f46 |
children | 30deba7bc8e2 |
rev | line source |
---|---|
1017
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
1 /** |
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
2 * Stone of Orthanc |
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
1017
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
6 * |
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
10 * the License, or (at your option) any later version. |
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
11 * |
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
15 * Affero General Public License for more details. |
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
16 * |
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
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 |
1017
069519ae389b
looks as if msvc2008 dislikes empty source files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
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 | 24 //#include "../Applications/Commands/BaseCommandFactory.h" |
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 | 27 //class CommandIncrement: public OrthancStone::BaseCommand<CommandIncrement> |
28 //{ | |
29 //public: | |
30 // static int counter; | |
31 // int increment_; | |
32 //public: | |
33 // CommandIncrement() | |
34 // : OrthancStone::BaseCommand<CommandIncrement>("increment"), | |
35 // increment_(0) | |
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 | 38 // virtual void Execute() |
39 // { | |
40 // counter += increment_; | |
41 // } | |
42 // virtual void Configure(const Json::Value& arguments) | |
43 // { | |
44 // increment_ = arguments["increment"].asInt(); | |
45 // } | |
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 | 48 //// COMMAND("name", "arg1", "int", "arg2", "string") |
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 | 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 | 54 //TEST(Commands, CreateNoop) |
55 //{ | |
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 | 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 | 60 // Json::Value cmdJson; |
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 |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
63 // std::unique_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 | 65 // ASSERT_TRUE(command.get() != NULL); |
66 // ASSERT_EQ("noop", command->GetName()); | |
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 | 69 //TEST(Commands, Execute) |
70 //{ | |
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 | 73 // factory.RegisterCommandClass<OrthancStone::NoopCommand>(); |
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 | 76 // Json::Value cmdJson; |
77 // cmdJson["command"] = "increment"; | |
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 |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
80 // std::unique_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 | 82 // ASSERT_TRUE(command.get() != NULL); |
83 // CommandIncrement::counter = 0; | |
84 // command->Execute(); | |
85 // ASSERT_EQ(2, CommandIncrement::counter); | |
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 | 88 //TEST(Commands, TryCreateUnknowCommand) |
89 //{ | |
90 // OrthancStone::BaseCommandFactory factory; | |
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 | 93 // Json::Value cmdJson; |
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 |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
96 // ASSERT_THROW(std::unique_ptr<OrthancStone::ICommand> command(factory.CreateFromJson(cmdJson)), Orthanc::OrthancException); |
307 | 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 | 99 //TEST(Commands, TryCreateCommandFromInvalidJson) |
100 //{ | |
101 // OrthancStone::BaseCommandFactory factory; | |
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 | 104 // Json::Value cmdJson; |
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 |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
107 // ASSERT_THROW(std::unique_ptr<OrthancStone::ICommand> command(factory.CreateFromJson(cmdJson)), Orthanc::OrthancException); |
307 | 108 //} |