aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/variables.c
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-07 10:12:57 +0900
committernsfisis <nsfisis@gmail.com>2026-02-07 10:12:57 +0900
commit0034f84a38e8cb41a753d2def1daccd14bbfd552 (patch)
tree6e734a8450c7f7fece5eda4c33ff72bc6ab277fb /tests/variables.c
parent107c517b22e88d760c375a4b9da6dffd6da26d85 (diff)
downloadducc-0034f84a38e8cb41a753d2def1daccd14bbfd552.tar.gz
ducc-0034f84a38e8cb41a753d2def1daccd14bbfd552.tar.zst
ducc-0034f84a38e8cb41a753d2def1daccd14bbfd552.zip
feat: implement global variables referencing string literals
Diffstat (limited to 'tests/variables.c')
-rw-r--r--tests/variables.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/variables.c b/tests/variables.c
index 5f09074..2ba28d1 100644
--- a/tests/variables.c
+++ b/tests/variables.c
@@ -19,14 +19,22 @@ char arr1[3] = {65, 66, 67};
short arr2[3] = {10, 20, 30};
int arr3[3] = {1, 2, 3};
-struct S {
+struct S1 {
int x, y;
};
-struct S arr4[] = {
+struct S1 arr4[] = {
{1, 2},
{3, 4},
};
+struct S2 {
+ const char* x;
+};
+struct S2 arr5[] = {
+ {"foo"},
+ {"bar"},
+};
+
int main() {
// global variables
*g_b = 123;
@@ -64,6 +72,9 @@ int main() {
ASSERT_EQ(3, arr4[1].x);
ASSERT_EQ(4, arr4[1].y);
+ ASSERT_EQ_STR("foo", arr5[0].x);
+ ASSERT_EQ_STR("bar", arr5[1].x);
+
// local variables
int foo;
foo = 42;