Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
DIAZ Jerome
MoReFEM
Commits
2abd3279
Commit
2abd3279
authored
Jul 25, 2019
by
GILLES Sebastien
Browse files
#1468 Enrich LuaOptionFile test to make it fail due to #1468 (which is not yet solved).
parent
b1c7d3bc
Changes
5
Hide whitespace changes
Inline
Side-by-side
MoReFEM.xcodeproj/project.pbxproj
View file @
2abd3279
...
...
@@ -4672,6 +4672,7 @@
BECF3E4622E99DCE00FF951A /* main_update_lua_file.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main_update_lua_file.cpp; sourceTree = "<group>"; };
BECF3E4722E99DF400FF951A /* main_update_lua_file.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main_update_lua_file.cpp; sourceTree = "<group>"; };
BECF3E4822E99E2C00FF951A /* main_update_lua_file.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = main_update_lua_file.cpp; path = RivlinCube/main_update_lua_file.cpp; sourceTree = "<group>"; };
BECF3E4C22E9B05A00FF951A /* map_in_vector.lua */ = {isa = PBXFileReference; lastKnownFileType = text; path = map_in_vector.lua; sourceTree = "<group>"; };
BED13351206519C700A3B0AA /* Penalization.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Penalization.hxx; sourceTree = "<group>"; };
BED13352206519C800A3B0AA /* Penalization.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Penalization.hpp; sourceTree = "<group>"; };
BED748E41906734200BAB761 /* main_test_ondomatic_numbering.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main_test_ondomatic_numbering.cpp; sourceTree = "<group>"; };
...
...
@@ -10247,6 +10248,7 @@
BEDE16A9204F385400DEFE08 /* CMakeLists.txt */,
BEDE16A0204EEC6600DEFE08 /* demo_lua_option_file.lua */,
BEDE16B3204FF5CE00DEFE08 /* redundancy.lua */,
BECF3E4C22E9B05A00FF951A /* map_in_vector.lua */,
BEDE169D204EEB0F00DEFE08 /* main.cpp */,
);
path = LuaOptionFile;
Sources/Test/Core/MoReFEMData/WriteLuaFile/demo.lua
View file @
2abd3279
...
...
@@ -84,8 +84,7 @@ ReactionCoefficient = 1.
TransientSource4
=
{
-- #1468 nature = { "lua_function", "constant", "piecewise_constant_by_domain"},
nature
=
{
"lua_function"
,
"constant"
,
"constant"
},
nature
=
{
"lua_function"
,
"constant"
,
"piecewise_constant_by_domain"
},
value
=
{
[[
...
...
@@ -94,8 +93,7 @@ TransientSource4 = {
end
]]
,
0
.,
0
.
}
-- #1468 { [1] = 0., [3] = 14.5, [4] = -31.231 } }
{
[
1
]
=
0
.,
[
3
]
=
14
.
5
,
[
4
]
=
-
31
.
231
}
}
}
-- TransientSource4
...
...
Sources/Test/Utilities/LuaOptionFile/main.cpp
View file @
2abd3279
...
...
@@ -7,11 +7,13 @@
//
*/
#include <sstream>
#include "Utilities/LuaOptionFile/LuaOptionFile.hpp"
#include "Utilities/Environment/Environment.hpp"
#include "Utilities/Numeric/Numeric.hpp"
#include "Utilities/InputData/LuaFunction.hpp"
#include "Utilities/Containers/Print.hpp"
#include "Core/SpatialLuaFunction.hpp"
...
...
@@ -118,7 +120,7 @@ BOOST_FIXTURE_TEST_CASE(parameters_properly_read, TestNS::FixtureNS::Environment
BOOST_CHECK_THROW
(
ReadLuaOptionFile
<
double
>
(
lua_option_file
,
"section1.invalid_value"
,
__FILE__
,
__LINE__
),
std
::
exception
);
//
This test should be added when Catch2 implements it; there's pressure on devs to provide it.
//
When I have time to investigate how to do so in Boost
// CHECK_ABORT(ReadLuaOptionFile<double>(lua_option_file, __FILE__, __LINE__));
}
...
...
@@ -221,7 +223,29 @@ BOOST_FIXTURE_TEST_CASE(invalid_lua, TestNS::FixtureNS::Environment)
"section3.invalid_function"
,
__FILE__
,
__LINE__
),
std
::
exception
);
}
BOOST_FIXTURE_TEST_CASE
(
map_in_vector
,
TestNS
::
FixtureNS
::
Environment
)
{
// Introduced after #1468, in which two braces on the same line wreak havoc...
decltype
(
auto
)
environment
=
Utilities
::
Environment
::
CreateOrGetInstance
(
__FILE__
,
__LINE__
);
decltype
(
auto
)
input_file
=
environment
.
SubstituteValues
(
"${MOREFEM_ROOT}/Sources/Test/Utilities/LuaOptionFile/map_in_vector.lua"
);
LuaOptionFile
lua
(
input_file
,
__FILE__
,
__LINE__
);
std
::
ostringstream
oconv
;
Utilities
::
PrintContainer
<>::
Do
(
lua
.
GetEntryKeyList
(),
oconv
);
BOOST_CHECK_EQUAL
(
oconv
.
str
(),
"[TransientSource4.nature, TransientSource4.value, "
"TransientSource5.nature, TransientSource5.value]"
);
}
PRAGMA_DIAGNOSTIC
(
pop
)
Sources/Test/Utilities/LuaOptionFile/map_in_vector.lua
0 → 100644
View file @
2abd3279
TransientSource4
=
{
nature
=
{
"lua_function"
,
"constant"
,
"piecewise_constant_by_domain"
},
value
=
{
[[
function (x, y, z)
return 100. * math.exp(-((x - 0.5)^2 + (y - 0.5)^2)/(0.1^2));
end
]]
,
0
.,
{
[
1
]
=
0
.,
[
3
]
=
14
.
5
,
[
4
]
=
-
31
.
231
}}
-- didn't pass before #1468
}
-- TransientSource4
TransientSource5
=
{
nature
=
{
"lua_function"
,
"constant"
,
"piecewise_constant_by_domain"
},
value
=
{
[[
function (x, y, z)
return 100. * math.exp(-((x - 0.5)^2 + (y - 0.5)^2)/(0.1^2));
end
]]
,
0
.,
{
[
1
]
=
0
.,
[
3
]
=
14
.
5
,
[
4
]
=
-
31
.
231
}
}
}
-- TransientSource5
Sources/Utilities/LuaOptionFile/LuaOptionFile.cpp
View file @
2abd3279
...
...
@@ -96,6 +96,9 @@ namespace MoReFEM
{
SetEntryKeyList
(
ExtractKeysFromFile
(
filename
));
std
::
cout
<<
"TMP"
<<
std
::
endl
;
Utilities
::
PrintContainer
<>::
Do
(
GetEntryKeyList
());
if
(
luaL_dofile
(
state_
,
filename
.
c_str
()))
{
std
::
ostringstream
oconv
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment