Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some refactoring #28

Merged
merged 1 commit into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utils/src/id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ std::string generate() {
std::random_device rd;
auto seed_data = std::array<int, std::mt19937::state_size>{};
std::generate(std::begin(seed_data), std::end(seed_data), std::ref(rd));
std::seed_seq seq(std::begin(seed_data), std::end(seed_data));
std::seed_seq seq(std::cbegin(seed_data), std::cend(seed_data));
std::mt19937 generator(seq);
uuids::uuid_random_generator gen{generator};

Expand Down
16 changes: 8 additions & 8 deletions test/weapon_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

#include <algorithm>
#include <iostream>
#include <range/v3/view.hpp>

#include "elevation/action/add_weapon.h"
#include "elevation/action/use_weapon.h"
#include "elevation/data_files/languages.h"
#include "elevation/entity/player.h"
#include "elevation/entity/plug.h"

namespace elevation {
TEST(weapon_test, UseWeapon) {
entity::Player player("Guillaume", 0);
Expand All @@ -20,15 +22,13 @@ TEST(weapon_test, UseWeapon) {

EXPECT_EQ(player.pseudo(), "Guillaume");

std::vector<std::string> weaponsName;
std::transform(std::cbegin(player.weapons()), std::cend(player.weapons()),
std::back_inserter(weaponsName),
[](const auto& weapon) { return weapon.name; });

std::vector<std::string> expectWeaponNames = {"Poing", "AK47"};
EXPECT_EQ(weaponsName.size(), expectWeaponNames.size());
for (std::size_t i = 0; i < weaponsName.size(); ++i) {
EXPECT_EQ(weaponsName[i], expectWeaponNames[i]);

EXPECT_EQ(player.weapons().size(), expectWeaponNames.size());

for (const auto& [playerWeapon, expectWeaponName] :
ranges::views::zip(player.weapons(), expectWeaponNames)) {
EXPECT_EQ(playerWeapon.name, expectWeaponName);
}
}

Expand Down