Skip to content

Commit ec20d73

Browse files
committed
Add AM_CONTAINER_OF() unit test
1 parent 9f17fb0 commit ec20d73

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [0-based versioning](https://0ver.org/).
1717
- [Cigarette Smokers Problem](https://en.wikipedia.org/wiki/Cigarette_smokers_problem) solution.
1818
- New `AM_ATOMIC_FETCH_ADD()` macro for atomic addition.
1919
- Clarification examples to FSM and HSW return macros.
20+
- `AM_CONTAINER_OF()` macro unit test.x
2021

2122
### Changed
2223

libs/common/test.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,19 @@ static void test_align(void) {
8383
}
8484
}
8585

86+
static void test_container_of(void) {
87+
struct foo {
88+
int a;
89+
int b;
90+
};
91+
struct foo foo = {.a = 1, .b = 2};
92+
int *bp = &foo.b;
93+
AM_ASSERT(1 == AM_CONTAINER_OF(bp, struct foo, b)->a);
94+
}
95+
8696
int main(void) {
8797
test_align();
98+
test_container_of();
8899

89100
return 0;
90101
}

0 commit comments

Comments
 (0)