You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
505 B
29 lines
505 B
6 years ago
|
#include <gtest/gtest.h>
|
||
4 years ago
|
#include "webfuse_provider/impl/util/container_of.h"
|
||
6 years ago
|
|
||
|
namespace
|
||
|
{
|
||
|
|
||
|
struct MyStruct
|
||
|
{
|
||
|
int first;
|
||
|
int second;
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
TEST(ContainerOf, FirstMember)
|
||
|
{
|
||
|
MyStruct my_struct = {23, 42};
|
||
|
|
||
|
int * first = &my_struct.first;
|
||
4 years ago
|
ASSERT_EQ(&my_struct, wfp_container_of(first, MyStruct, first));
|
||
6 years ago
|
}
|
||
|
|
||
|
TEST(ContainerOf, SecondMember)
|
||
|
{
|
||
|
MyStruct my_struct = {23, 42};
|
||
|
|
||
|
int * second = &my_struct.second;
|
||
4 years ago
|
ASSERT_EQ(&my_struct, wfp_container_of(second, MyStruct, second));
|
||
6 years ago
|
}
|