Readme & tasks 1,2, 4, 5 - #6
Conversation
|
Доки по программе в отдельным ПРом нужно делать |
|
|
||
| TEST(Template, Simple) { ASSERT_EQ(true, true); } | ||
| TEST(Template, Easy) { | ||
| std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11}; |
There was a problem hiding this comment.
warning: variable 'vec' is not initialized [cppcoreguidelines-init-variables]
| std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11}; | |
| std::vector<int> vec = 0{1, 10, 7, 6, 3, 2, 1, 11}; |
| ASSERT_EQ(rmq.findMin(1, 7), 1); | ||
| } | ||
| TEST(Template, Medium) { | ||
| std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11}; |
There was a problem hiding this comment.
warning: variable 'vec' is not initialized [cppcoreguidelines-init-variables]
| std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11}; | |
| std::vector<int> vec = 0{1, 10, 7, 6, 3, 2, 1, 11}; |
| ASSERT_EQ(rmq.findMin(6, 7), 1); | ||
| } | ||
| TEST(Template, Hard) { | ||
| std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11}; |
There was a problem hiding this comment.
warning: variable 'vec' is not initialized [cppcoreguidelines-init-variables]
| std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11}; | |
| std::vector<int> vec = 0{1, 10, 7, 6, 3, 2, 1, 11}; |
| ASSERT_EQ(rmq.findMin(3, 4), 3); | ||
| } | ||
| TEST(Template, Harder) { | ||
| std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11, 12}; |
There was a problem hiding this comment.
warning: variable 'vec' is not initialized [cppcoreguidelines-init-variables]
| std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11, 12}; | |
| std::vector<int> vec = 0{1, 10, 7, 6, 3, 2, 1, 11, 12}; |
| ASSERT_EQ(rmq.findMin(7, 8), 11); | ||
| } | ||
| TEST(Template, Comlicated) { | ||
| std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11, 12, 1, 1, 1}; |
There was a problem hiding this comment.
warning: variable 'vec' is not initialized [cppcoreguidelines-init-variables]
| std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11, 12, 1, 1, 1}; | |
| std::vector<int> vec = 0{1, 10, 7, 6, 3, 2, 1, 11, 12, 1, 1, 1}; |
| ASSERT_EQ(graph.topologySort(0), res); | ||
| } | ||
| TEST(TopologySort, Comlex) { | ||
| std::vector<std::vector<int>> input = {{1, 2}, {3}, {3, 4}, {1, 4}, {0}, {}, {7, 8}, {10}, {9, 10}, {6, 11}, {7}, {}, {9, 10, 11}}; |
There was a problem hiding this comment.
warning: variable 'input' is not initialized [cppcoreguidelines-init-variables]
| std::vector<std::vector<int>> input = {{1, 2}, {3}, {3, 4}, {1, 4}, {0}, {}, {7, 8}, {10}, {9, 10}, {6, 11}, {7}, {}, {9, 10, 11}}; | |
| std::vector<std::vector<int>> input = 0 = {{1, 2}, {3}, {3, 4}, {1, 4}, {0}, {}, {7, 8}, {10}, {9, 10}, {6, 11}, {7}, {}, {9, 10, 11}}; |
| TEST(TopologySort, Comlex) { | ||
| std::vector<std::vector<int>> input = {{1, 2}, {3}, {3, 4}, {1, 4}, {0}, {}, {7, 8}, {10}, {9, 10}, {6, 11}, {7}, {}, {9, 10, 11}}; | ||
| Graph graph(input); | ||
| std::vector<int> res = {5, 12, 9, 11, 6, 8, 7, 10, 0, 2, 1, 3, 4}; |
There was a problem hiding this comment.
warning: variable 'res' is not initialized [cppcoreguidelines-init-variables]
| std::vector<int> res = {5, 12, 9, 11, 6, 8, 7, 10, 0, 2, 1, 3, 4}; | |
| std::vector<int> res = 0 = {5, 12, 9, 11, 6, 8, 7, 10, 0, 2, 1, 3, 4}; |
| } | ||
|
|
||
| TEST(TopologySort, Empty) { | ||
| std::vector<std::vector<int>> input = {{0}}; |
There was a problem hiding this comment.
warning: variable 'input' is not initialized [cppcoreguidelines-init-variables]
| std::vector<std::vector<int>> input = {{0}}; | |
| std::vector<std::vector<int>> input = 0 = {{0}}; |
| TEST(TopologySort, Empty) { | ||
| std::vector<std::vector<int>> input = {{0}}; | ||
| Graph graph(input); | ||
| std::vector<int> res = {0}; |
There was a problem hiding this comment.
warning: variable 'res' is not initialized [cppcoreguidelines-init-variables]
| std::vector<int> res = {0}; | |
| std::vector<int> res = 0 = {0}; |
| } | ||
|
|
||
| TEST(TopologySort, FullGraphLoops) { | ||
| std::vector<std::vector<int>> input = {{0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}}; |
There was a problem hiding this comment.
warning: variable 'input' is not initialized [cppcoreguidelines-init-variables]
| std::vector<std::vector<int>> input = {{0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}}; | |
| std::vector<std::vector<int>> input = 0 = {{0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}}; |
| { | ||
| if(colors[i] == 0) | ||
| { | ||
| still_white = i; |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
still_white = i;
^|
|
||
| Graph::Graph(std::vector<std::vector<int>> new_graph) | ||
| { | ||
| graph_list = new_graph; |
There was a problem hiding this comment.
warning: 'graph_list' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
task_01/src/topology_sort.cpp:63:
- Graph::Graph(std::vector<std::vector<int>> new_graph)
+ Graph::Graph(std::vector<std::vector<int>> new_graph) : graph_list(new_graph)| graph_list = new_graph; | |
|
|
||
| Graph::Graph(std::vector<std::vector<int>> new_graph) | ||
| { | ||
| graph_list = new_graph; |
There was a problem hiding this comment.
warning: parameter 'new_graph' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]
graph_list = new_graph;
^this fix will not be applied because it overlaps with another fix
| Graph::Graph(std::vector<std::vector<int>> new_graph) | ||
| { | ||
| graph_list = new_graph; | ||
| timer = 0; |
There was a problem hiding this comment.
warning: 'timer' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
task_01/src/topology_sort.cpp:63:
- Graph::Graph(std::vector<std::vector<int>> new_graph)
+ Graph::Graph(std::vector<std::vector<int>> new_graph), timer(0)| timer = 0; | |
| } | ||
|
|
||
| std::set<std::pair<int, int>> findBridges (const std::vector<std::vector<int>>& graph){ | ||
| int time = 0; |
There was a problem hiding this comment.
warning: variable 'time' of type 'int' can be declared 'const' [misc-const-correctness]
| int time = 0; | |
| int const time = 0; |
| size_t pow_len = std::pow(2, pow); | ||
| minimum_table.push_back(input_vector); | ||
| minimum_table[0].resize(pow_len, __INT_MAX__); | ||
| int current_pow = pow - 1; |
There was a problem hiding this comment.
warning: Value stored to 'current_pow' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
int current_pow = pow - 1;
^Additional context
task_05/src/RMQ.cpp:9: Value stored to 'current_pow' during its initialization is never read
int current_pow = pow - 1;
^| size_t pow_len = std::pow(2, pow); | ||
| minimum_table.push_back(input_vector); | ||
| minimum_table[0].resize(pow_len, __INT_MAX__); | ||
| int current_pow = pow - 1; |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
int current_pow = pow - 1;
^| int RMQ::findMin(const unsigned int left, const unsigned int right){ | ||
| if(left > right || left < 0 || right > minimum_table[0].size()) | ||
| throw std::out_of_range ("wrong border arguments"); | ||
| size_t row = std::floor(std::log2(right - left + 1)); |
There was a problem hiding this comment.
warning: variable 'row' of type 'size_t' (aka 'unsigned long') can be declared 'const' [misc-const-correctness]
| size_t row = std::floor(std::log2(right - left + 1)); | |
| size_t const row = std::floor(std::log2(right - left + 1)); |
| if(left > right || left < 0 || right > minimum_table[0].size()) | ||
| throw std::out_of_range ("wrong border arguments"); | ||
| size_t row = std::floor(std::log2(right - left + 1)); | ||
| return std::min(minimum_table[row][left], minimum_table[row][right - std::pow(2, row) + 1]); |
There was a problem hiding this comment.
warning: narrowing conversion from 'typename __gnu_cxx::__promote_2<int, unsigned long>::__type' (aka 'double') to 'size_type' (aka 'unsigned long') [cppcoreguidelines-narrowing-conversions]
return std::min(minimum_table[row][left], minimum_table[row][right - std::pow(2, row) + 1]);
^| @@ -1,6 +1,72 @@ | |||
|
|
|||
| #include <gtest/gtest.h> | |||
There was a problem hiding this comment.
warning: 'gtest/gtest.h' file not found [clang-diagnostic-error]
#include <gtest/gtest.h>
^
No description provided.