[Bf-blender-cvs] [3f6357b970f] functions: initialize llvm for tests
Jacques Lucke
noreply at git.blender.org
Sun Apr 28 00:30:17 CEST 2019
Commit: 3f6357b970f8cb69bfc937e182a16ad9ecf029aa
Author: Jacques Lucke
Date: Sat Apr 27 23:40:53 2019 +0200
Branches: functions
https://developer.blender.org/rB3f6357b970f8cb69bfc937e182a16ad9ecf029aa
initialize llvm for tests
===================================================================
M tests/gtests/functions/functions_test.cc
===================================================================
diff --git a/tests/gtests/functions/functions_test.cc b/tests/gtests/functions/functions_test.cc
index 13048a9c517..d76d5489184 100644
--- a/tests/gtests/functions/functions_test.cc
+++ b/tests/gtests/functions/functions_test.cc
@@ -7,7 +7,15 @@ using namespace FN;
auto *body = FN->body<TupleCallBody>(); \
FN_TUPLE_CALL_ALLOC_TUPLES(body, fn_in, fn_out);
-TEST(functions_impl, MultiplyFloats)
+class functions_impl : public testing::Test {
+ protected:
+ void SetUp() override
+ {
+ FN_initialize();
+ }
+};
+
+TEST_F(functions_impl, MultiplyFloats)
{
PREPARE_TUPLE_CALL_TEST(Functions::GET_FN_multiply_floats());
@@ -19,7 +27,7 @@ TEST(functions_impl, MultiplyFloats)
EXPECT_EQ(fn_out.get<float>(0), 80);
}
-TEST(functions_impl, FloatRange)
+TEST_F(functions_impl, FloatRange)
{
PREPARE_TUPLE_CALL_TEST(Functions::GET_FN_float_range());
@@ -38,3 +46,17 @@ TEST(functions_impl, FloatRange)
EXPECT_EQ(ptr[2], 16);
EXPECT_EQ(ptr[3], 23);
}
+
+TEST_F(functions_impl, AddFloats)
+{
+ auto fn = Functions::GET_FN_add_floats();
+ derive_TupleCallBody_from_LLVMBuildIRBody(fn, *(new llvm::LLVMContext()));
+ PREPARE_TUPLE_CALL_TEST(fn);
+
+ fn_in.set<float>(0, 3.5f);
+ fn_in.set<float>(1, 1.5f);
+
+ body->call__setup_execution_context(fn_in, fn_out);
+
+ EXPECT_EQ(fn_out.get<float>(0), 5.0f);
+}
More information about the Bf-blender-cvs
mailing list