-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrclrTest.cpp
85 lines (74 loc) · 1.96 KB
/
strclrTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <functional>
#include "libft.h"
#include "voidVal.hpp"
#include "memVal.hpp"
#include "strclrTest.hpp"
strclrTest::strclrTest()
{
#ifdef FT_STRCLR_EXIST
funToTestExist = true;
#else
funToTestExist = false;
#endif
}
int strclrTest::launchTest()
{
strclrTest test;
test.startTest("ft_strclr(char *s)");
return test.errCount;
}
void strclrTest::processTest()
{
#ifdef FT_STRCLR_EXIST
spMemVal baseS = mkSpMemVal(nullptr, 0, "s");
spMemVal testS = mkSpMemVal(nullptr, 0, "s");
std::function<spVoidVal(spMemVal)> baseFunction =
[&](spMemVal s)
{
(void)s;
if (baseS->getVal() != nullptr)
{
bzero(baseS->getVal(), strlen((char*)(baseS->getVal())));
}
return mkSpVoidVal();
};
std::function<spVoidVal(spMemVal)> testFunction =
[&](spMemVal s)
{
(void)s;
ft_strclr((char*)(testS->getVal()));
return mkSpVoidVal();
};
auto testValsFun =
[&](bool printRes) {return compareVals(printRes, std::pair<spMemVal, spMemVal>(baseS, testS));};
testThisFunAndVals(baseFunction, testFunction, testValsFun, baseS);
{
char sValBase[] = "";
char sValTest[] = "";
baseS->setValAndLen(sValBase, sizeof(sValBase));
testS->setValAndLen(sValTest, sizeof(sValTest));
testThisFunAndVals(baseFunction, testFunction, testValsFun, baseS);
}
{
char sValBase[] = "O";
char sValTest[] = "O";
baseS->setValAndLen(sValBase, sizeof(sValBase));
testS->setValAndLen(sValTest, sizeof(sValTest));
testThisFunAndVals(baseFunction, testFunction, testValsFun, baseS);
}
{
char sValBase[] = "SALUT";
char sValTest[] = "SALUT";
baseS->setValAndLen(sValBase, sizeof(sValBase));
testS->setValAndLen(sValTest, sizeof(sValTest));
testThisFunAndVals(baseFunction, testFunction, testValsFun, baseS);
}
{
char sValBase[] = "SAL\0UT";
char sValTest[] = "SAL\0UT";
baseS->setValAndLen(sValBase, sizeof(sValBase));
testS->setValAndLen(sValTest, sizeof(sValTest));
testThisFunAndVals(baseFunction, testFunction, testValsFun, baseS);
}
#endif
}