How to fix: "unknown location(0): fatal error: in "TestCase": memory access violation at address: 0x00000008: no mapping at fault address

-1

I have encountered an error: "How to fix: "unknown location(0): fatal error: in "RentsManagerTestCase": memory access violation at address: 0x00000008: no mapping at fault address" when trying to run my test.

I think there might be a problem with the constructor for RentsManager and also with the fact that it refers to something that doesn't exist. Maybe somehow converting my ClientsRepository to ClientsRepositoryPtr of type shared_ptr would help?

My test code:

BOOST_AUTO_TEST_CASE(RentsManagerTestCase) {

    VehicleRepository repo;
    repo.addVehicle(VehiclePtr(new Car('A', 1500, "SWD87ML", 110)));
    repo.addVehicle(VehiclePtr(new Car('B', 1000, "SWD89UW", 80)));
    repo.addVehicle(VehiclePtr(new Car('C', 1350, "EZG56A3", 100)));
    repo.addVehicle(VehiclePtr(new Car('D', 900, "EL789I", 70)));

    BOOST_REQUIRE_EQUAL(repo.getVehiclesSize(),4);

        ClientRepository repo2;

        ClientPtr c1(new Client("Anna", "Kowalska", "254"));
        ClientTypePtr type1(new ClientType("Business"));

        repo2.createClient(c1);

        c1->setClientType(type1);

    BOOST_REQUIRE_EQUAL(type1, c1->getClientType());
        shared_ptr<ClientRepository> r2(new ClientRepository(repo2));

        RentsRepositoryPtr currentRents;
        RentsRepositoryPtr archiveRents;

        RentsManager rents(currentRents, archiveRents, r2);

        rents.rentVehicle(c1, repo.searchForVehicle(1));
        rents.rentVehicle(c1, repo.searchForVehicle(2));

    BOOST_REQUIRE_EQUAL(rents.checkClientRentBallance(c1), 2);
    rents.returnVehicle(c1, repo.searchForVehicle(1));

    BOOST_REQUIRE_EQUAL(rents.checkClientRentBallance(c1), 1);
}

Constructor for RentsManager I've created:

RentsManager::RentsManager(const RentsRepositoryPtr &currentRents, const RentsRepositoryPtr &archiveRents,
                       const ClientRepositoryPtr &clientRepository) : currentRents(currentRents),
                                                                      archiveRents(archiveRents),
                                                                      clientRepository(clientRepository) {}
c++
boost
boost-test
asked on Stack Overflow Jan 17, 2019 by Inspring

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0