Есть менеджер памяти, под который мне нужно написать тесты. Дело в том, что я сам менеджер подключила: и в проект добавила и прагму написала, но всё равно по непонятным мне причинам всплывают ошибки линковщика типа
Ошибка 4 error LNK2019: ссылка на неразрешенный внешний символ "public: class std::basic_string,class std::allocator > __thiscall Tests::readWriteTest(void)" (?readWriteTest@Tests@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) в функции "void __cdecl readWriteTest(void)" (?readWriteTest@@YAXXZ) E:\MV2010\memoryTester\memoryTester\main.obj memoryTester
Что я сделала не так!?
#pragma comment (lib,"Lab1.lib")
#include "Tests.h"
#include "mMemory.h"
#include <string.h>
#include <vector>
using namespace std;
Tests::Tests(){}
string initTest()
{
string str;
for(int n=0; n<12; ++n){
for(int szPage=0; szPage<32; ++szPage){
int retval = _init(n,szPage);
if(n<1 || szPage<1){
if(retval != -1){
str = "ERORR! init is wrong!";
return str;
}
} else{
if(retval != 0){
str = "ERORR! init is wrong!";
return str;
}
}
}
}
str = "You are init your manager.Our congratulations";
return str;
}
string mallocTest(){
string str;
for(int n=1; n<12; ++n){
for(int szPage=0; szPage<32; ++szPage){
vector<int> freeSize(n,szPage);
int retval = _init(n,szPage);
int bufCount = rand()%32;
VA *ptr = new VA[bufCount];
int *bufSize = new int[bufCount];
char **bufValue = new char *[bufCount];
for(int i=0;i<bufCount; ++i){
bufSize[i] = rand()%32;
bufValue[i] = new char[bufSize[i]];
for(int j=0; j<bufSize[i];++j){
bufValue[i][j] = '0' + rand()%10;
}
retval = _malloc(&ptr[i],bufSize[i]);
if(bufSize[i]<1 || (bufSize[i]>szPage)){
if(retval != -1){
str = "ERROR: malloc return code must be -1 but was " + retval;
return str;
}
} else{
bool area = false;
int freeS = freeSize.size();
for(int p=0;p<freeS;++p){
if(freeSize[p]>=bufSize[i]){
freeSize[p] = bufSize[i];
area = true;
break;
}
} if(area){
if(retval != 0){
str = "ERROR: malloc return code must be 0 but was " + retval;
return str;
}
} else{
if(retval != -2){
str = "ERROR: malloc return code must be -2 but was " + retval;
return str;
}
}
}
}
}
}
str = "Our congratulations testing malloc is OK";
return str;
}
string freeTest(){
for(int n=1;n<12;++n){
for(int szPage=1;szPage<32;++szPage){
string str;
_init(n,szPage);
int retval = _free(NULL);
if(retval != -1){
str = "ERROR: free return code must be -1 but was " + retval;
return str;
}
for(int i=0;i<n*2;++i){
VA buf;
retval = _malloc(&buf,szPage);
if(retval ==-2)
{return "ERROR: not enough memory for malloc"; }
retval = _free(buf);
if(retval != 0)
{return "ERROR: free return code must be 0 but was " + retval;}
}
}
}
return "Our congratulations testing free is successful";
}
string readWriteTest(){
for(int n=1; n<12; ++n){
for(int szPage=4;szPage<32;++szPage){
VA buf;
int retval;
_malloc(&buf,szPage/2);
string str = "";
for(int i=0;i<szPage;++i){
str += "@";
// l +="%";
}
char *ch = new char[str.length()];
strcpy(ch,str.c_str());
int value = _write(buf,ch,szPage/2);
if(value == 1)
retval = _read(NULL,&buf,szPage);
if(retval != -1){
return "ERROR: read return code must be -1 but was " + retval;
}
retval = _read(buf,NULL,szPage);
if(retval != -1){
return "ERROR: read return code must be -1 but was " + retval;
}
retval = _read(buf,&buf,szPage+1);
if(retval != -1){
return "ERROR: malloc return code must be -1 but was " + retval;
}
//VA buff;
//manager._malloc(&buff,szPage/2);
//char *chr = new char[l.length()];
//strcpy(chr,l.c_str());
//manager._write(buff,chr,szPage/2);
//manager._read(buf,buff,szPage/4);
_free(buf);
}
}
return "Congratulations! It's successful work";
}
Tests::~Tests(void)
{}
<code lang="cpp">
#pragma once
/*
*/
#include <iostream>
using namespace std;
class Tests
{
private:
public:
Tests();
string initTest();
string mallocTest();
string freeTest();
string readWriteTest();
~Tests();
};
<code lang="cpp">
#pragma once
/*
*/
#include <iostream>
using namespace std;
class Tests
{
private:
public:
Tests();
string initTest();
string mallocTest();
string freeTest();
string readWriteTest();
~Tests();
};
</code>