From e58b20f68d8b9ecedceaa03f3e78c560127c3527 Mon Sep 17 00:00:00 2001 From: Mithil Poojary Date: Mon, 5 Oct 2020 04:28:08 +0530 Subject: [PATCH] Add C file test --- tests/syntax-tests/highlighted/C/test.c | 62 +++++++++++++++++++++++++ tests/syntax-tests/source/C/test.c | 62 +++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 tests/syntax-tests/highlighted/C/test.c create mode 100644 tests/syntax-tests/source/C/test.c diff --git a/tests/syntax-tests/highlighted/C/test.c b/tests/syntax-tests/highlighted/C/test.c new file mode 100644 index 00000000..723e75a3 --- /dev/null +++ b/tests/syntax-tests/highlighted/C/test.c @@ -0,0 +1,62 @@ +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> + +void test_function() +{ +#define TEST +#ifdef TEST + printf("TEST is defined\n"); +#endif +} + +struct Node +{ + int val; + struct Node *next; +}; + +int main(int argc, char **argv) +{ + /* This C program was written to help bat + * with its syntax highlighting tests + */ + + // Calling test function + test_function(); + struct Node *head = NULL; + head = (struct Node *)malloc(sizeof(struct Node *)); + head->val = -1; + if (head->val == 1 * -1) + { + head->val = 10; + } + else + { + head->val = argc; + } + int t = head->val, count = 0; + free(head); + while (t--) + { + count++; + } + for (int i = t; i < count; ++i) + { + do + { + --count; + } while (false); + } + enum chars + { + M, + I, + T, + H, + L + }; + char *string = "string"; + printf("true is #define true %d\n", true); + return 0; +} diff --git a/tests/syntax-tests/source/C/test.c b/tests/syntax-tests/source/C/test.c new file mode 100644 index 00000000..9ca7255d --- /dev/null +++ b/tests/syntax-tests/source/C/test.c @@ -0,0 +1,62 @@ +#include +#include +#include + +void test_function() +{ +#define TEST +#ifdef TEST + printf("TEST is defined\n"); +#endif +} + +struct Node +{ + int val; + struct Node *next; +}; + +int main(int argc, char **argv) +{ + /* This C program was written to help bat + * with its syntax highlighting tests + */ + + // Calling test function + test_function(); + struct Node *head = NULL; + head = (struct Node *)malloc(sizeof(struct Node *)); + head->val = -1; + if (head->val == 1 * -1) + { + head->val = 10; + } + else + { + head->val = argc; + } + int t = head->val, count = 0; + free(head); + while (t--) + { + count++; + } + for (int i = t; i < count; ++i) + { + do + { + --count; + } while (false); + } + enum chars + { + M, + I, + T, + H, + L + }; + char *string = "string"; + printf("true is #define true %d\n", true); + return 0; +}