Debian Codegraph @

tests/src/test_commandqueue.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/tests/src/test_commandqueue.cpp`/
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #include <catch2/catch_all.hpp>
5
6 #include "core/commandqueue.h"cxx . . $ `<file>/src/core/commandqueue.h`/
7 #include <QString>
8
9 namespace Testscxx . . $ Tests/::CommandQueuecxx . . $ Tests/CommandQueue/ {
10
11 class CommandQueueTestAdaptercxx . . $ Tests/CommandQueue/CommandQueueTestAdapter# : public ::CommandQueuecxx . . $ CommandQueue#
12 {
13 public:
14 using ::CommandQueuecxx . . $ CommandQueue#::CommandQueuecxx . . $ Tests/CommandQueue/CommandQueueTestAdapter#CommandQueueTestAdapter(728e2687d891636c).;
15
16 using ::CommandQueuecxx . . $ CommandQueue#::addcxx . . $ Tests/CommandQueue/CommandQueueTestAdapter#add(358a66d3ce188717).;
17 using ::CommandQueuecxx . . $ CommandQueue#::commandscxx . . $ Tests/CommandQueue/CommandQueueTestAdapter#commands(d258e1be62a8acf4).;
18 using ::CommandQueuecxx . . $ CommandQueue#::hasCommandQueuedForcxx . . $ Tests/CommandQueue/CommandQueueTestAdapter#hasCommandQueuedFor(7c222eea44a24d43).;
19 using ::CommandQueuecxx . . $ CommandQueue#::toRawDatacxx . . $ Tests/CommandQueue/CommandQueueTestAdapter#toRawData(b3c286cec66e09f4).;
20 };
21
22 TEST_CASEcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:144:11`!("CommandQueue tests", "[CommandQueue]")
23 {
24 CommandQueueTestAdaptercxx . . $ Tests/CommandQueue/CommandQueueTestAdapter# ts({cxx . . $ std/unordered_set#unordered_set(cd91ea9215506ca7)."multi-cmd-file"});
25
26 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Initially, is empty")
27 {
28 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.commands().size() == 0);
29
30 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Commands can be added")
31 {
32 ts.addcxx . . $ CommandQueue#add(358a66d3ce188717).({cxx . . $ std/pair#pair(62e1774a2dc03c82)."path", "value"});
33
34 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.commands().size() == 1);
35
36 stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#> cmdcxx . . $ std/pair#pair(62e1774a2dc03c82).{"path", "value"};
37 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.commands().front() == cmd);
38
39 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Queuing an already queued command has no effect")
40 {
41 ts.addcxx . . $ CommandQueue#add(358a66d3ce188717).({cxx . . $ std/pair#pair(62e1774a2dc03c82)."path", "value"});
42
43 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.commands().size() == 1);
44 }
45
46 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Queuing a command for a multi-command file inserts the command "
47 "just after the last queued command for that file")
48 {
49 ts.addcxx . . $ CommandQueue#add(358a66d3ce188717).({cxx . . $ std/pair#pair(62e1774a2dc03c82)."multi-cmd-file", "1"});
50 ts.addcxx . . $ CommandQueue#add(358a66d3ce188717).({cxx . . $ std/pair#pair(62e1774a2dc03c82)."other", "value"});
51 ts.addcxx . . $ CommandQueue#add(358a66d3ce188717).({cxx . . $ std/pair#pair(62e1774a2dc03c82)."multi-cmd-file", "2"});
52
53 auto &commands = ts.commandscxx . . $ CommandQueue#commands(d258e1be62a8acf4).();
54 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands.size() == 4);
55
56 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands[0].first == "path");
57 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands[0].second == "value");
58 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands[1].first == "multi-cmd-file");
59 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands[1].second == "1");
60 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands[2].first == "multi-cmd-file");
61 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands[2].second == "2");
62 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands[3].first == "other");
63 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands[3].second == "value");
64 }
65
66 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!(
67 "Queuing a command for a non multi-command file removes the last "
68 "queued command for that file and inserts the new command at the end")
69 {
70 ts.addcxx . . $ CommandQueue#add(358a66d3ce188717).({cxx . . $ std/pair#pair(62e1774a2dc03c82)."other", "value"});
71
72 auto &commands = ts.commandscxx . . $ CommandQueue#commands(d258e1be62a8acf4).();
73 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands.size() == 2);
74
75 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands[0].first == "path");
76 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands[0].second == "value");
77 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands[1].first == "other");
78 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands[1].second == "value");
79
80 ts.addcxx . . $ CommandQueue#add(358a66d3ce188717).({cxx . . $ std/pair#pair(62e1774a2dc03c82)."path", "value1"});
81
82 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands[0].first == "other");
83 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands[0].second == "value");
84 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands[1].first == "path");
85 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands[1].second == "value1");
86 }
87
88 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Commands are transformed into raw data...")
89 {
90 auto data = ts.toRawDatacxx . . $ CommandQueue#toRawData(b3c286cec66e09f4).();
91
92 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(data == QByteArray("path\0value\0", 11));
93
94 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("The queue is cleared")
95 {
96 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.commands().size() == 0);
97 }
98 }
99 }
100 }
101 }
102
103 } // namespace Tests::CommandQueue