aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-05-04 15:40:44 +0900
committernsfisis <nsfisis@gmail.com>2025-05-04 15:40:44 +0900
commite121612e7636a32f6b3b1944c41a45c190984f3d (patch)
treee67a5343f58a5b6544e0335428f8f7538ce09abf /tests
parent1a224ae3f0e9565e0740288c176967659d856928 (diff)
downloadP4Dcc-e121612e7636a32f6b3b1944c41a45c190984f3d.tar.gz
P4Dcc-e121612e7636a32f6b3b1944c41a45c190984f3d.tar.zst
P4Dcc-e121612e7636a32f6b3b1944c41a45c190984f3d.zip
pointer arithmetic operations
Diffstat (limited to 'tests')
-rw-r--r--tests/022.sh2
-rw-r--r--tests/023.sh2
-rw-r--r--tests/024.sh40
3 files changed, 44 insertions, 0 deletions
diff --git a/tests/022.sh b/tests/022.sh
index e9c8103..e5749f2 100644
--- a/tests/022.sh
+++ b/tests/022.sh
@@ -4,6 +4,8 @@ cat <<'EOF' > expected
42 42
EOF
bash ../../test_diff.sh <<'EOF'
+int printf();
+
int main() {
int x;
int* y;
diff --git a/tests/023.sh b/tests/023.sh
index 86e2aa6..cb77c22 100644
--- a/tests/023.sh
+++ b/tests/023.sh
@@ -18,6 +18,8 @@ sizeof(long***) = 8
sizeof(void***) = 8
EOF
bash ../../test_diff.sh <<'EOF'
+int printf();
+
int main() {
printf("sizeof(int) = %d\n", sizeof(int));
printf("sizeof(int*) = %d\n", sizeof(int*));
diff --git a/tests/024.sh b/tests/024.sh
new file mode 100644
index 0000000..5f9ff6f
--- /dev/null
+++ b/tests/024.sh
@@ -0,0 +1,40 @@
+set -e
+
+cat <<'EOF' > expected
+3
+3
+3
+EOF
+bash ../../test_diff.sh <<'EOF'
+int printf();
+
+int main() {
+ char c;
+ int i;
+ long l;
+ c = 42;
+ i = 42*2;
+ l = 42*3;
+
+ char* cp1;
+ char* cp2;
+ int* ip1;
+ int* ip2;
+ long* lp1;
+ long* lp2;
+
+ cp1 = &c;
+ cp2 = &c + 3;
+ printf("%d\n", cp2 - cp1);
+
+ ip1 = &i;
+ ip2 = &i + 3;
+ printf("%d\n", ip2 - ip1);
+
+ lp1 = &l;
+ lp2 = &l + 3;
+ printf("%d\n", lp2 - lp1);
+
+ return 0;
+}
+EOF