Rename C api
Summary: This renames the core C api to use the new Yoga branding. Differential Revision: D4259190 fbshipit-source-id: 26c8b356ca464d4304f5f9dc4192bff10cea2dc9
This commit is contained in:
committed by
Facebook Github Bot
parent
f7cc614d67
commit
dda24b1e23
@@ -7,7 +7,7 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#include <CSSLayout/CSSLayout.h>
|
||||
#include <CSSLayout/Yoga.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
extern int32_t gNodeInstanceCount;
|
||||
@@ -37,41 +37,41 @@ static void testFree(void *ptr) {
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
TEST(CSSLayoutTest, memory_func_default) {
|
||||
gNodeInstanceCount = 0; // Reset CSSNode instance count for memory func test
|
||||
CSSLayoutSetMemoryFuncs(NULL, NULL, NULL, NULL);
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
const CSSNodeRef root_child0 = CSSNodeNew();
|
||||
CSSNodeInsertChild(root, root_child0, 0);
|
||||
CSSNodeFreeRecursive(root);
|
||||
TEST(YogaTest, memory_func_default) {
|
||||
gNodeInstanceCount = 0; // Reset YGNode instance count for memory func test
|
||||
YGSetMemoryFuncs(NULL, NULL, NULL, NULL);
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
const YGNodeRef root_child0 = YGNodeNew();
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
YGNodeFreeRecursive(root);
|
||||
}
|
||||
|
||||
TEST(CSSLayoutTest, memory_func_test_funcs) {
|
||||
gNodeInstanceCount = 0; // Reset CSSNode instance count for memory func test
|
||||
CSSLayoutSetMemoryFuncs(&testMalloc, &testCalloc, &testRealloc, &testFree);
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
TEST(YogaTest, memory_func_test_funcs) {
|
||||
gNodeInstanceCount = 0; // Reset YGNode instance count for memory func test
|
||||
YGSetMemoryFuncs(&testMalloc, &testCalloc, &testRealloc, &testFree);
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
const CSSNodeRef child = CSSNodeNew();
|
||||
CSSNodeInsertChild(root, child, 0);
|
||||
const YGNodeRef child = YGNodeNew();
|
||||
YGNodeInsertChild(root, child, 0);
|
||||
}
|
||||
CSSNodeFreeRecursive(root);
|
||||
YGNodeFreeRecursive(root);
|
||||
ASSERT_NE(testMallocCount, 0);
|
||||
ASSERT_NE(testCallocCount, 0);
|
||||
ASSERT_NE(testReallocCount, 0);
|
||||
ASSERT_NE(testFreeCount, 0);
|
||||
CSSLayoutSetMemoryFuncs(NULL, NULL, NULL, NULL);
|
||||
YGSetMemoryFuncs(NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
TEST(CSSLayoutTest, memory_func_assert_zero_nodes) {
|
||||
gNodeInstanceCount = 0; // Reset CSSNode instance count for memory func test
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
ASSERT_DEATH(CSSLayoutSetMemoryFuncs(&testMalloc, &testCalloc, &testRealloc, &testFree), "Cannot set memory functions: all node must be freed first");
|
||||
CSSNodeFreeRecursive(root);
|
||||
TEST(YogaTest, memory_func_assert_zero_nodes) {
|
||||
gNodeInstanceCount = 0; // Reset YGNode instance count for memory func test
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
ASSERT_DEATH(YGSetMemoryFuncs(&testMalloc, &testCalloc, &testRealloc, &testFree), "Cannot set memory functions: all node must be freed first");
|
||||
YGNodeFreeRecursive(root);
|
||||
}
|
||||
|
||||
TEST(CSSLayoutTest, memory_func_assert_all_non_null) {
|
||||
gNodeInstanceCount = 0; // Reset CSSNode instance count for memory func test
|
||||
ASSERT_DEATH(CSSLayoutSetMemoryFuncs(NULL, &testCalloc, &testRealloc, &testFree), "Cannot set memory functions: functions must be all NULL or Non-NULL");
|
||||
TEST(YogaTest, memory_func_assert_all_non_null) {
|
||||
gNodeInstanceCount = 0; // Reset YGNode instance count for memory func test
|
||||
ASSERT_DEATH(YGSetMemoryFuncs(NULL, &testCalloc, &testRealloc, &testFree), "Cannot set memory functions: functions must be all NULL or Non-NULL");
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user