aboutsummaryrefslogtreecommitdiffstats
path: root/tests/indent/c
diff options
context:
space:
mode:
authorJędrzej Boczar <yendreij@gmail.com>2021-04-22 20:53:30 +0200
committerKiyan <yazdani.kiyan@protonmail.com>2021-04-23 21:21:38 +0200
commit63a88c873f3643aad9208488765dc53618edd40e (patch)
treefb233a54b0dae8a6af1a12dfecb9cd85cbdb4f64 /tests/indent/c
parentignore Lua indent test files when doing style-check (diff)
downloadnvim-treesitter-63a88c873f3643aad9208488765dc53618edd40e.tar
nvim-treesitter-63a88c873f3643aad9208488765dc53618edd40e.tar.gz
nvim-treesitter-63a88c873f3643aad9208488765dc53618edd40e.tar.bz2
nvim-treesitter-63a88c873f3643aad9208488765dc53618edd40e.tar.lz
nvim-treesitter-63a88c873f3643aad9208488765dc53618edd40e.tar.xz
nvim-treesitter-63a88c873f3643aad9208488765dc53618edd40e.tar.zst
nvim-treesitter-63a88c873f3643aad9208488765dc53618edd40e.zip
move all tests to top-level tests/ directory
Diffstat (limited to 'tests/indent/c')
-rw-r--r--tests/indent/c/array.c14
-rw-r--r--tests/indent/c/comment.c8
-rw-r--r--tests/indent/c/cond.c10
-rw-r--r--tests/indent/c/enum.c5
-rw-r--r--tests/indent/c/expr.c12
-rw-r--r--tests/indent/c/func.c33
-rw-r--r--tests/indent/c/label.c7
-rw-r--r--tests/indent/c/loop.c16
-rw-r--r--tests/indent/c/no_braces.c12
-rw-r--r--tests/indent/c/preproc_cond.c10
-rw-r--r--tests/indent/c/preproc_func.c9
-rw-r--r--tests/indent/c/string.c5
-rw-r--r--tests/indent/c/struct.c11
-rw-r--r--tests/indent/c/switch.c16
-rw-r--r--tests/indent/c/ternary.c6
15 files changed, 174 insertions, 0 deletions
diff --git a/tests/indent/c/array.c b/tests/indent/c/array.c
new file mode 100644
index 000000000..5bb67c2c8
--- /dev/null
+++ b/tests/indent/c/array.c
@@ -0,0 +1,14 @@
+int x[] = {
+ 1, 2, 3,
+ 4, 5,
+ 6
+};
+
+int y[][2] = {
+ {0, 1},
+ {1, 2},
+ {
+ 2,
+ 3
+ },
+};
diff --git a/tests/indent/c/comment.c b/tests/indent/c/comment.c
new file mode 100644
index 000000000..b32de8218
--- /dev/null
+++ b/tests/indent/c/comment.c
@@ -0,0 +1,8 @@
+/**
+ * Function foo
+ * @param[out] x output
+ * @param[in] x input
+ */
+void foo(int *x, int y) {
+ *x = y;
+}
diff --git a/tests/indent/c/cond.c b/tests/indent/c/cond.c
new file mode 100644
index 000000000..1ecb22d98
--- /dev/null
+++ b/tests/indent/c/cond.c
@@ -0,0 +1,10 @@
+void foo(int x)
+{
+ if (x > 10) {
+ return;
+ } else if (x < -10) {
+ x = -10;
+ } else {
+ x = -x;
+ }
+}
diff --git a/tests/indent/c/enum.c b/tests/indent/c/enum.c
new file mode 100644
index 000000000..bb6b0dc30
--- /dev/null
+++ b/tests/indent/c/enum.c
@@ -0,0 +1,5 @@
+enum foo {
+ A = 1,
+ B,
+ C,
+};
diff --git a/tests/indent/c/expr.c b/tests/indent/c/expr.c
new file mode 100644
index 000000000..cafb11120
--- /dev/null
+++ b/tests/indent/c/expr.c
@@ -0,0 +1,12 @@
+void foo(int x, int y)
+{
+ if ((x*x - y*y > 0) ||
+ (x == 1 || y == 1) &&
+ (x != 2 && y != 2)
+ ) {
+ return;
+ }
+
+ int z = (x + y) *
+ (x - y);
+}
diff --git a/tests/indent/c/func.c b/tests/indent/c/func.c
new file mode 100644
index 000000000..c188acc01
--- /dev/null
+++ b/tests/indent/c/func.c
@@ -0,0 +1,33 @@
+int f1(int x) {
+ return 1;
+}
+
+int f2(int x)
+{
+ return 1;
+}
+
+int f3(
+ int x
+) {
+ return 1;
+}
+
+int f4(
+ int x,
+ int y
+) {
+ return 1;
+}
+
+int f5(int x,
+ int y)
+{
+ return 1;
+}
+
+int
+f6(int x, int y)
+{
+ return 1;
+}
diff --git a/tests/indent/c/label.c b/tests/indent/c/label.c
new file mode 100644
index 000000000..36b40e23a
--- /dev/null
+++ b/tests/indent/c/label.c
@@ -0,0 +1,7 @@
+int foo(int x)
+{
+ goto error;
+ return 0;
+error:
+ return 1;
+}
diff --git a/tests/indent/c/loop.c b/tests/indent/c/loop.c
new file mode 100644
index 000000000..facaebb6b
--- /dev/null
+++ b/tests/indent/c/loop.c
@@ -0,0 +1,16 @@
+void foo(int x)
+{
+ while (x > 0) {
+ x--;
+ continue;
+ }
+
+ for (int i = 0; i < 5; ++i) {
+ x++;
+ break;
+ }
+
+ do {
+ x++;
+ } while (x < 0);
+}
diff --git a/tests/indent/c/no_braces.c b/tests/indent/c/no_braces.c
new file mode 100644
index 000000000..544ac01d0
--- /dev/null
+++ b/tests/indent/c/no_braces.c
@@ -0,0 +1,12 @@
+int foo(int x) {
+ if (x > 10)
+ return 10;
+ else
+ return x;
+
+ while (1)
+ x++;
+
+ for (int i = 0; i < 3; ++i)
+ x--;
+}
diff --git a/tests/indent/c/preproc_cond.c b/tests/indent/c/preproc_cond.c
new file mode 100644
index 000000000..b85440aa9
--- /dev/null
+++ b/tests/indent/c/preproc_cond.c
@@ -0,0 +1,10 @@
+void foo(int x)
+{
+ x = x + 1;
+#if 1
+ x = x + 2;
+#else
+ x = x + 3;
+#endif
+ x = x + 4;
+}
diff --git a/tests/indent/c/preproc_func.c b/tests/indent/c/preproc_func.c
new file mode 100644
index 000000000..f1f38feb9
--- /dev/null
+++ b/tests/indent/c/preproc_func.c
@@ -0,0 +1,9 @@
+#define FOO(x) do { \
+ x = x + 1; \
+ x = x / 2; \
+ } while (x > 0);
+
+void foo(int x)
+{
+ FOO(x);
+}
diff --git a/tests/indent/c/string.c b/tests/indent/c/string.c
new file mode 100644
index 000000000..2d5177e00
--- /dev/null
+++ b/tests/indent/c/string.c
@@ -0,0 +1,5 @@
+const char *a = "hello \
+world";
+
+const char *b = "hello "
+ "world";
diff --git a/tests/indent/c/struct.c b/tests/indent/c/struct.c
new file mode 100644
index 000000000..8cc2b6b21
--- /dev/null
+++ b/tests/indent/c/struct.c
@@ -0,0 +1,11 @@
+struct foo {
+ int a;
+ struct bar {
+ int x;
+ } b;
+};
+
+union baz {
+ struct foo;
+ int x;
+};
diff --git a/tests/indent/c/switch.c b/tests/indent/c/switch.c
new file mode 100644
index 000000000..4003bdb1d
--- /dev/null
+++ b/tests/indent/c/switch.c
@@ -0,0 +1,16 @@
+void foo(int x) {
+ switch (x) {
+ case 1:
+ x += 1;
+ break;
+ case 2: x += 2;
+ break;
+ case 3: x += 3; break;
+ case 4: {
+ x += 4;
+ break;
+ }
+ default:
+ x = -x;
+ }
+}
diff --git a/tests/indent/c/ternary.c b/tests/indent/c/ternary.c
new file mode 100644
index 000000000..2e40b382e
--- /dev/null
+++ b/tests/indent/c/ternary.c
@@ -0,0 +1,6 @@
+void foo(int x)
+{
+ int y = (x > 10) ? 10
+ : (x < -10) ? -10
+ : x;
+}