Skip to content

Commit 2d07945

Browse files
committed
fixed co-pilot comments
1 parent 0715a6e commit 2d07945

25 files changed

+116
-974
lines changed
Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,39 @@
1-
#include "cucumber/messages/pickle_table_row.hpp"
1+
#include "cucumber/messages/pickle_table.hpp"
22
#include "cucumber_cpp/CucumberCpp.hpp"
3-
#include "gmock/gmock.h"
4-
#include "gtest/gtest.h"
53
#include <cstddef>
64
#include <gmock/gmock.h>
7-
#include <span>
5+
#include <gtest/gtest.h>
86
#include <vector>
97

108
STEP(R"(the following table is transposed:)")
119
{
12-
std::vector<cucumber::messages::pickle_table_row> transposedTable;
13-
transposedTable.reserve(this->table->front().cells.size());
14-
for (std::size_t colIdx = 0; colIdx < this->table->front().cells.size(); ++colIdx)
15-
transposedTable.emplace_back().cells.resize(this->table->size());
10+
auto transposedTable = context.Emplace<cucumber::messages::pickle_table>();
11+
transposedTable->rows.reserve(this->dataTable->rows[0].cells.size());
12+
for (std::size_t colIdx = 0; colIdx < this->dataTable->rows[0].cells.size(); ++colIdx)
13+
transposedTable->rows.emplace_back().cells.resize(this->dataTable->rows.size());
1614

17-
for (std::size_t rowIdx = 0; rowIdx < this->table->size(); ++rowIdx)
18-
for (std::size_t colIdx = 0; colIdx < this->table->begin()[rowIdx].cells.size(); ++colIdx)
19-
transposedTable[colIdx].cells[rowIdx] = this->table->begin()[rowIdx].cells[colIdx];
20-
21-
context.Insert(transposedTable);
15+
for (std::size_t rowIdx = 0; rowIdx < this->dataTable->rows.size(); ++rowIdx)
16+
for (std::size_t colIdx = 0; colIdx < this->dataTable->rows[rowIdx].cells.size(); ++colIdx)
17+
transposedTable->rows[colIdx].cells[rowIdx] = this->dataTable->rows[rowIdx].cells[colIdx];
2218
}
2319

2420
STEP(R"(it should be:)")
2521
{
26-
std::span<const cucumber::messages::pickle_table_row> expected = context.Get<std::vector<cucumber::messages::pickle_table_row>>();
27-
const auto& actual = *table;
28-
const auto rows = expected.size();
29-
ASSERT_THAT(rows, testing::Eq(actual.size()));
22+
const auto& actualTable = context.Get<cucumber::messages::pickle_table>();
23+
const auto& expectedTalbe = dataTable;
24+
25+
const auto rows = actualTable.rows.size();
26+
ASSERT_THAT(rows, testing::Eq(expectedTalbe->rows.size()));
27+
3028
for (auto rowIdx = 0; rowIdx < rows; ++rowIdx)
3129
{
32-
const auto columns = expected[rowIdx].cells.size();
33-
ASSERT_THAT(columns, testing::Eq(actual[rowIdx].cells.size()));
30+
const auto columns = expectedTalbe->rows[rowIdx].cells.size();
31+
ASSERT_THAT(columns, testing::Eq(actualTable.rows[rowIdx].cells.size()));
3432
for (auto colIdx = 0; colIdx < columns; ++colIdx)
3533
{
36-
const auto& expectedCell = expected[rowIdx].cells[colIdx];
37-
const auto& actualCell = actual[rowIdx].cells[colIdx];
34+
const auto& expectedCell = expectedTalbe->rows[rowIdx].cells[colIdx];
35+
const auto& actualCell = actualTable.rows[rowIdx].cells[colIdx];
3836
EXPECT_THAT(expectedCell.value, testing::StrEq(actualCell.value)) << "at row " << rowIdx << " column " << colIdx;
3937
}
4038
}
4139
}
42-
43-
// import assert from 'node:assert'
44-
// import { DataTable, When, Then } from '@cucumber/fake-cucumber'
45-
46-
// When('the following table is transposed:', function (table: DataTable) {
47-
// this.transposed = table.transpose()
48-
// })
49-
50-
// Then('it should be:', function (expected: DataTable) {
51-
// assert.deepStrictEqual(this.transposed.raw(), expected.raw())
52-
// }

cucumber_cpp/example/steps/Steps.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "gmock/gmock.h"
44
#include "gtest/gtest.h"
55
#include <cstdint>
6-
#include <iostream>
76
#include <string>
87

98
GIVEN(R"(a background step)")
@@ -13,11 +12,11 @@ GIVEN(R"(a background step)")
1312

1413
GIVEN(R"(a simple data table)")
1514
{
16-
[[maybe_unused]] const auto row0col0 = table.value()[0].cells[0].value;
17-
[[maybe_unused]] const auto row0col1 = table.value()[0].cells[1].value;
15+
[[maybe_unused]] const auto row0col0 = dataTable->rows[0].cells[0].value;
16+
[[maybe_unused]] const auto row0col1 = dataTable->rows[0].cells[1].value;
1817

19-
[[maybe_unused]] const auto row1col0 = table.value()[1].cells[0].value;
20-
[[maybe_unused]] const auto row1col1 = table.value()[1].cells[1].value;
18+
[[maybe_unused]] const auto row1col0 = dataTable->rows[1].cells[0].value;
19+
[[maybe_unused]] const auto row1col1 = dataTable->rows[1].cells[1].value;
2120
}
2221

2322
GIVEN(R"(there are {int} cucumbers)", (std::int32_t num))
@@ -99,7 +98,7 @@ STEP("this step should be skipped")
9998

10099
STEP(R"(a step stores the value at row {int} and column {int} from the table:)", (std::int32_t row, std::int32_t column))
101100
{
102-
context.EmplaceAt<std::string>("cell", table.value()[row].cells[column].value);
101+
context.EmplaceAt<std::string>("cell", dataTable->rows[row].cells[column].value);
103102
}
104103

105104
STEP(R"(the value should be {string})", (const std::string& expected_value))

cucumber_cpp/library/StepRegistry.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "cucumber/gherkin/id_generator.hpp"
55
#include "cucumber/messages/pickle_doc_string.hpp"
6+
#include "cucumber/messages/pickle_table.hpp"
67
#include "cucumber/messages/pickle_table_row.hpp"
78
#include "cucumber/messages/step_definition_pattern_type.hpp"
89
#include "cucumber_cpp/library/Body.hpp"
@@ -34,12 +35,12 @@
3435

3536
namespace cucumber_cpp::library
3637
{
37-
using StepFactory = std::unique_ptr<Body> (&)(util::Broadcaster& broadCaster, Context&, engine::StepOrHookStarted stepOrHookStarted, std::optional<std::span<const cucumber::messages::pickle_table_row>>, const std::optional<cucumber::messages::pickle_doc_string>&);
38+
using StepFactory = std::unique_ptr<Body> (&)(util::Broadcaster& broadCaster, Context&, engine::StepOrHookStarted stepOrHookStarted, const std::optional<cucumber::messages::pickle_table>&, const std::optional<cucumber::messages::pickle_doc_string>&);
3839

3940
template<class T>
40-
std::unique_ptr<Body> StepBodyFactory(util::Broadcaster& broadCaster, Context& context, engine::StepOrHookStarted stepOrHookStarted, std::optional<std::span<const cucumber::messages::pickle_table_row>> table, const std::optional<cucumber::messages::pickle_doc_string>& docString)
41+
std::unique_ptr<Body> StepBodyFactory(util::Broadcaster& broadCaster, Context& context, engine::StepOrHookStarted stepOrHookStarted, const std::optional<cucumber::messages::pickle_table>& dataTable, const std::optional<cucumber::messages::pickle_doc_string>& docString)
4142
{
42-
return std::make_unique<T>(broadCaster, context, stepOrHookStarted, table, docString);
43+
return std::make_unique<T>(broadCaster, context, stepOrHookStarted, dataTable, docString);
4344
}
4445

4546
struct StepMatch

cucumber_cpp/library/engine/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ target_link_libraries(cucumber_cpp.library.engine PUBLIC
2424
)
2525

2626
if (CCR_BUILD_TESTS)
27-
# add_subdirectory(test)
27+
add_subdirectory(test)
2828
# add_subdirectory(test_helper)
2929
endif()

cucumber_cpp/library/engine/Step.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
namespace cucumber_cpp::library::engine
1414
{
15-
Step::Step(util::Broadcaster& broadCaster, Context& context, engine::StepOrHookStarted stepOrHookStarted, std::optional<std::span<const cucumber::messages::pickle_table_row>> table, const std::optional<cucumber::messages::pickle_doc_string>& docString)
15+
Step::Step(util::Broadcaster& broadCaster, Context& context, engine::StepOrHookStarted stepOrHookStarted, const std::optional<cucumber::messages::pickle_table>& dataTable, const std::optional<cucumber::messages::pickle_doc_string>& docString)
1616
: ExecutionContext{ broadCaster, context, stepOrHookStarted }
17-
, table{ table }
17+
, dataTable{ dataTable }
1818
, docString{ docString }
1919
{}
2020

cucumber_cpp/library/engine/Step.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// IWYU pragma: friend cucumber_cpp/.*
66

77
#include "cucumber/messages/pickle_doc_string.hpp"
8+
#include "cucumber/messages/pickle_table.hpp"
89
#include "cucumber/messages/pickle_table_row.hpp"
910
#include "cucumber_cpp/library/Context.hpp"
1011
#include "cucumber_cpp/library/engine/ExecutionContext.hpp"
@@ -20,7 +21,7 @@ namespace cucumber_cpp::library::engine
2021
{
2122
struct Step : ExecutionContext
2223
{
23-
Step(util::Broadcaster& broadCaster, Context& context, engine::StepOrHookStarted stepOrHookStarted, std::optional<std::span<const cucumber::messages::pickle_table_row>> table, const std::optional<cucumber::messages::pickle_doc_string>& docString);
24+
Step(util::Broadcaster& broadCaster, Context& context, engine::StepOrHookStarted stepOrHookStarted, const std::optional<cucumber::messages::pickle_table>& dataTable, const std::optional<cucumber::messages::pickle_doc_string>& docString);
2425
virtual ~Step() = default;
2526

2627
virtual void SetUp()
@@ -38,7 +39,7 @@ namespace cucumber_cpp::library::engine
3839
void When(const std::string& step) const;
3940
void Then(const std::string& step) const;
4041

41-
std::optional<std::span<const cucumber::messages::pickle_table_row>> table;
42+
const std::optional<cucumber::messages::pickle_table>& dataTable;
4243
const std::optional<cucumber::messages::pickle_doc_string>& docString;
4344
};
4445
}

cucumber_cpp/library/engine/test/CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@ add_test(NAME cucumber_cpp.library.engine.test COMMAND cucumber_cpp.library.engi
44
target_link_libraries(cucumber_cpp.library.engine.test PUBLIC
55
cucumber_cpp.library.engine
66
gmock_main
7-
cucumber_cpp.library.engine.test_helper
8-
cucumber_cpp.library.engine.test_helper.steps
7+
# cucumber_cpp.library.engine.test_helper
8+
# cucumber_cpp.library.engine.test_helper.steps
99
)
1010

1111
target_sources(cucumber_cpp.library.engine.test PRIVATE
12-
TestContextManager.cpp
13-
TestFailureHandler.cpp
14-
TestFeatureFactory.cpp
15-
TestHookExecutor.cpp
16-
TestHookExecutorHooks.cpp
1712
TestStep.cpp
1813
TestStringTo.cpp
1914
)

cucumber_cpp/library/engine/test/TestContextManager.cpp

Lines changed: 0 additions & 139 deletions
This file was deleted.

cucumber_cpp/library/engine/test/TestFailureHandler.cpp

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)