Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
0eaddbd0
Commit
0eaddbd0
authored
Nov 6, 2019
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Finish CFunctionProcessor tests
Also checks that all functions of CMathModule are tested
parent
6675ff79
No related branches found
No related tags found
1 merge request
!37
Feature/language
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_CFunctionProcessor.cpp
+228
-9
228 additions, 9 deletions
tests/test_CFunctionProcessor.cpp
with
228 additions
and
9 deletions
tests/test_CFunctionProcessor.cpp
+
228
−
9
View file @
0eaddbd0
...
@@ -12,17 +12,9 @@
...
@@ -12,17 +12,9 @@
#include
<ASTNodeExpressionBuilder.hpp>
#include
<ASTNodeExpressionBuilder.hpp>
#include
<ASTNodeAffectationExpressionBuilder.hpp>
#include
<ASTSymbolTableBuilder.hpp>
#include
<ASTSymbolTableBuilder.hpp>
#include
<ASTPrinter.hpp>
#include
<CMathModule.hpp>
#include
<Demangle.hpp>
#include
<PEGGrammar.hpp>
#include
<sstream>
#define CHECK_CFUNCTION_EVALUATION_RESULT(data, variable_name, expected_value) \
#define CHECK_CFUNCTION_EVALUATION_RESULT(data, variable_name, expected_value) \
{ \
{ \
...
@@ -74,6 +66,15 @@ R x = sqrt(4);
...
@@ -74,6 +66,15 @@ R x = sqrt(4);
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
sqrt
(
4l
)});
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
sqrt
(
4l
)});
}
}
{
// abs
tested_function_set
.
insert
(
"abs"
);
std
::
string_view
data
=
R"(
import math;
R x = abs(-3.4);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
abs
(
-
3.4
)});
}
{
// sin
{
// sin
tested_function_set
.
insert
(
"sin"
);
tested_function_set
.
insert
(
"sin"
);
std
::
string_view
data
=
R"(
std
::
string_view
data
=
R"(
...
@@ -82,5 +83,223 @@ R x = sin(1.3);
...
@@ -82,5 +83,223 @@ R x = sin(1.3);
)"
;
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
sin
(
1.3
)});
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
sin
(
1.3
)});
}
}
{
// cos
tested_function_set
.
insert
(
"cos"
);
std
::
string_view
data
=
R"(
import math;
R x = cos(1.3);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
cos
(
1.3
)});
}
{
// tan
tested_function_set
.
insert
(
"tan"
);
std
::
string_view
data
=
R"(
import math;
R x = tan(1.3);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
tan
(
1.3
)});
}
{
// asin
tested_function_set
.
insert
(
"asin"
);
std
::
string_view
data
=
R"(
import math;
R x = asin(0.7);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
asin
(
0.7
)});
}
{
// acos
tested_function_set
.
insert
(
"acos"
);
std
::
string_view
data
=
R"(
import math;
R x = acos(0.7);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
acos
(
0.7
)});
}
{
// atan
tested_function_set
.
insert
(
"atan"
);
std
::
string_view
data
=
R"(
import math;
R x = atan(0.7);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
atan
(
0.7
)});
}
{
// atan2
tested_function_set
.
insert
(
"atan2"
);
std
::
string_view
data
=
R"(
import math;
R x = atan2(0.7, 0.4);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
atan2
(
0.7
,
0.4
)});
}
{
// sinh
tested_function_set
.
insert
(
"sinh"
);
std
::
string_view
data
=
R"(
import math;
R x = sinh(0.6);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
sinh
(
0.6
)});
}
{
// cosh
tested_function_set
.
insert
(
"cosh"
);
std
::
string_view
data
=
R"(
import math;
R x = cosh(1.7);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
cosh
(
1.7
)});
}
{
// tanh
tested_function_set
.
insert
(
"tanh"
);
std
::
string_view
data
=
R"(
import math;
R x = tanh(0.6);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
tanh
(
0.6
)});
}
{
// asinh
tested_function_set
.
insert
(
"asinh"
);
std
::
string_view
data
=
R"(
import math;
R x = asinh(0.6);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
asinh
(
0.6
)});
}
{
// acosh
tested_function_set
.
insert
(
"acosh"
);
std
::
string_view
data
=
R"(
import math;
R x = acosh(1.7);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
acosh
(
1.7
)});
}
{
// tanh
tested_function_set
.
insert
(
"atanh"
);
std
::
string_view
data
=
R"(
import math;
R x = atanh(0.6);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
atanh
(
0.6
)});
}
{
// exp
tested_function_set
.
insert
(
"exp"
);
std
::
string_view
data
=
R"(
import math;
R x = exp(1.7);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
exp
(
1.7
)});
}
{
// log
tested_function_set
.
insert
(
"log"
);
std
::
string_view
data
=
R"(
import math;
R x = log(1.6);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
log
(
1.6
)});
}
{
// pow
tested_function_set
.
insert
(
"pow"
);
std
::
string_view
data
=
R"(
import math;
R x = pow(1.6, 2.3);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
std
::
pow
(
1.6
,
2.3
)});
}
{
// exp
tested_function_set
.
insert
(
"nearbyint"
);
std
::
string_view
data
=
R"(
import math;
R x = nearbyint(1.7);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
2
});
}
{
// ceil
tested_function_set
.
insert
(
"ceil"
);
std
::
string_view
data
=
R"(
import math;
R x = ceil(-1.2);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
-
1
});
}
{
// floor
tested_function_set
.
insert
(
"floor"
);
std
::
string_view
data
=
R"(
import math;
R x = floor(-1.2);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
-
2
});
}
{
// trunc
tested_function_set
.
insert
(
"trunc"
);
std
::
string_view
data
=
R"(
import math;
R x = trunc(-0.2) + trunc(0.7);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
0
});
}
{
// round
tested_function_set
.
insert
(
"round"
);
std
::
string_view
data
=
R"(
import math;
R x = round(-1.2);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
-
1
});
}
{
// lround
tested_function_set
.
insert
(
"lround"
);
std
::
string_view
data
=
R"(
import math;
Z i = lround(-1.2);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"i"
,
int64_t
{
-
1
});
}
{
// rint
tested_function_set
.
insert
(
"rint"
);
std
::
string_view
data
=
R"(
import math;
R x = rint(-1.2);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"x"
,
double
{
-
1
});
}
{
// lrint
tested_function_set
.
insert
(
"lrint"
);
std
::
string_view
data
=
R"(
import math;
Z i = lrint(-1.2);
)"
;
CHECK_CFUNCTION_EVALUATION_RESULT
(
data
,
"i"
,
int64_t
{
-
1
});
}
CMathModule
math_module
;
bool
missing_test
=
false
;
for
(
auto
[
cmath_name
,
c_function
]
:
math_module
.
getNameCFunctionsMap
())
{
if
(
tested_function_set
.
find
(
cmath_name
)
==
tested_function_set
.
end
())
{
UNSCOPED_INFO
(
"function '"
<<
cmath_name
<<
"' is NOT tested"
);
missing_test
=
true
;
}
}
REQUIRE_FALSE
(
missing_test
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment