Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-add support for using Yoga without exceptions #1006

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tests/YGMeasureTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,11 @@ TEST(YogaDeathTest, cannot_add_child_to_node_with_measure_func) {
root->setMeasureFunc(_measure);

const YGNodeRef root_child0 = YGNodeNew();
#if defined(__cpp_exceptions)
ASSERT_THROW(YGNodeInsertChild(root, root_child0, 0), std::logic_error);
#else // !defined(__cpp_exceptions)
ASSERT_DEATH(YGNodeInsertChild(root, root_child0, 0), "Cannot add child.*");
#endif // defined(__cpp_exceptions)
YGNodeFree(root_child0);
YGNodeFreeRecursive(root);
}
Expand All @@ -589,7 +593,11 @@ TEST(YogaDeathTest, cannot_add_nonnull_measure_func_to_non_leaf_node) {
const YGNodeRef root = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNew();
YGNodeInsertChild(root, root_child0, 0);
#if defined(__cpp_exceptions)
ASSERT_THROW(root->setMeasureFunc(_measure), std::logic_error);
#else // !defined(__cpp_exceptions)
ASSERT_DEATH(root->setMeasureFunc(_measure), "Cannot set measure function.*");
#endif // defined(__cpp_exceptions)
YGNodeFreeRecursive(root);
}

Expand Down
4 changes: 4 additions & 0 deletions yoga/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,9 @@ YGFloatOptional YGFloatOptionalMax(YGFloatOptional op1, YGFloatOptional op2) {
}

void throwLogicalErrorWithMessage(const char* message) {
#if defined(__cpp_exceptions)
throw std::logic_error(message);
#else // !defined(__cpp_exceptions)
std::terminate();
#endif // defined(__cpp_exceptions)
}