Skip to content

Commit

Permalink
Add tests for nested struct literals
Browse files Browse the repository at this point in the history
  • Loading branch information
IGI-111 authored and eqrion committed Nov 5, 2018
1 parent d163daa commit 9861755
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/expectations/both/prefixed_struct_literal_deep.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>

typedef struct PREFIXBar {
int32_t a;
} PREFIXBar;

typedef struct PREFIXFoo {
int32_t a;
uint32_t b;
PREFIXBar bar;
} PREFIXFoo;

#define PREFIXVAL (PREFIXFoo){ .a = 42, .b = 1337, .bar = (PREFIXBar){ .a = 323 } }

void root(PREFIXFoo x);
17 changes: 17 additions & 0 deletions tests/expectations/prefixed_struct_literal_deep.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>

typedef struct {
int32_t a;
} PREFIXBar;

typedef struct {
int32_t a;
uint32_t b;
PREFIXBar bar;
} PREFIXFoo;

#define PREFIXVAL (PREFIXFoo){ .a = 42, .b = 1337, .bar = (PREFIXBar){ .a = 323 } }

void root(PREFIXFoo x);
20 changes: 20 additions & 0 deletions tests/expectations/prefixed_struct_literal_deep.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <cstdint>
#include <cstdlib>

struct PREFIXBar {
int32_t a;
};

struct PREFIXFoo {
int32_t a;
uint32_t b;
PREFIXBar bar;
};

static const PREFIXFoo PREFIXVAL = (PREFIXFoo){ .a = 42, .b = 1337, .bar = (PREFIXBar){ .a = 323 } };

extern "C" {

void root(PREFIXFoo x);

} // extern "C"
17 changes: 17 additions & 0 deletions tests/expectations/tag/prefixed_struct_literal_deep.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>

struct PREFIXBar {
int32_t a;
};

struct PREFIXFoo {
int32_t a;
uint32_t b;
struct PREFIXBar bar;
};

#define PREFIXVAL (PREFIXFoo){ .a = 42, .b = 1337, .bar = (PREFIXBar){ .a = 323 } }

void root(struct PREFIXFoo x);
20 changes: 20 additions & 0 deletions tests/rust/prefixed_struct_literal_deep.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#[repr(C)]
struct Foo {
a: i32,
b: u32,
bar: Bar,
}

#[repr(C)]
struct Bar {
a: i32,
}

const VAL: Foo = Foo {
a: 42,
b: 1337,
bar: Bar { a: 323 },
};

#[no_mangle]
pub extern "C" fn root(x: Foo) {}
2 changes: 2 additions & 0 deletions tests/rust/prefixed_struct_literal_deep.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[export]
prefix = "PREFIX"

0 comments on commit 9861755

Please sign in to comment.