Skip to content

Commit

Permalink
Some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeLepape committed Dec 30, 2023
1 parent 95ae054 commit 32f8b93
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
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

0 comments on commit 32f8b93

Please sign in to comment.