mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-10-31 07:04:04 +00:00 
			
		
		
		
	Add C file test
This commit is contained in:
		
				
					committed by
					
						 David Peter
						David Peter
					
				
			
			
				
	
			
			
			
						parent
						
							0ce697daba
						
					
				
				
					commit
					e58b20f68d
				
			
							
								
								
									
										62
									
								
								tests/syntax-tests/highlighted/C/test.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								tests/syntax-tests/highlighted/C/test.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,62 @@ | ||||
| [38;2;249;38;114m#include[0m[38;2;190;132;255m [0m[38;2;230;219;116m<[0m[38;2;230;219;116mstdio.h[0m[38;2;230;219;116m>[0m | ||||
| [38;2;249;38;114m#include[0m[38;2;190;132;255m [0m[38;2;230;219;116m<[0m[38;2;230;219;116mstdlib.h[0m[38;2;230;219;116m>[0m | ||||
| [38;2;249;38;114m#include[0m[38;2;190;132;255m [0m[38;2;230;219;116m<[0m[38;2;230;219;116mstdbool.h[0m[38;2;230;219;116m>[0m | ||||
|  | ||||
| [3;38;2;102;217;239mvoid[0m[38;2;248;248;242m [0m[38;2;166;226;46mtest_function[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m | ||||
| [38;2;248;248;242m{[0m | ||||
| [38;2;249;38;114m#define[0m[38;2;190;132;255m [0m[38;2;166;226;46mTEST[0m | ||||
| [38;2;249;38;114m#ifdef[0m[38;2;190;132;255m TEST[0m | ||||
| [38;2;248;248;242m    [0m[38;2;102;217;239mprintf[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mTEST is defined[0m[38;2;190;132;255m\n[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m | ||||
| [38;2;249;38;114m#endif[0m | ||||
| [38;2;248;248;242m}[0m | ||||
|  | ||||
| [3;38;2;102;217;239mstruct[0m[38;2;248;248;242m [0m[38;2;166;226;46mNode[0m | ||||
| [38;2;248;248;242m{[0m | ||||
| [38;2;248;248;242m    [0m[3;38;2;102;217;239mint[0m[38;2;248;248;242m val[0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m    [0m[3;38;2;102;217;239mstruct[0m[38;2;248;248;242m [0m[38;2;166;226;46mNode[0m[38;2;248;248;242m *next[0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m}[0m[38;2;248;248;242m;[0m | ||||
|  | ||||
| [3;38;2;102;217;239mint[0m[38;2;248;248;242m [0m[38;2;166;226;46mmain[0m[38;2;248;248;242m([0m[3;38;2;102;217;239mint[0m[38;2;248;248;242m [0m[3;38;2;253;151;31margc[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mchar[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;249;38;114m*[0m[3;38;2;253;151;31margv[0m[38;2;248;248;242m)[0m | ||||
| [38;2;248;248;242m{[0m | ||||
| [38;2;248;248;242m    [0m[38;2;117;113;94m/*[0m[38;2;117;113;94m This C program was written to help bat[0m | ||||
| [38;2;117;113;94m     [0m[38;2;117;113;94m*[0m[38;2;117;113;94m with its syntax highlighting tests[0m | ||||
| [38;2;117;113;94m     [0m[38;2;117;113;94m*/[0m | ||||
|  | ||||
| [38;2;248;248;242m    [0m[38;2;117;113;94m//[0m[38;2;117;113;94m Calling test function[0m | ||||
| [38;2;248;248;242m    [0m[38;2;248;248;242mtest_function[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m    [0m[3;38;2;102;217;239mstruct[0m[38;2;248;248;242m Node [0m[38;2;249;38;114m*[0m[38;2;248;248;242mhead [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255mNULL[0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m    head [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[3;38;2;102;217;239mstruct[0m[38;2;248;248;242m Node [0m[38;2;249;38;114m*[0m[38;2;248;248;242m)[0m[38;2;102;217;239mmalloc[0m[38;2;248;248;242m([0m[38;2;249;38;114msizeof[0m[38;2;248;248;242m([0m[3;38;2;102;217;239mstruct[0m[38;2;248;248;242m Node [0m[38;2;249;38;114m*[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m    head[0m[38;2;248;248;242m->[0m[38;2;248;248;242mval [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;249;38;114m-[0m[38;2;190;132;255m1[0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m    [0m[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mhead[0m[38;2;248;248;242m->[0m[38;2;248;248;242mval [0m[38;2;249;38;114m==[0m[38;2;248;248;242m [0m[38;2;190;132;255m1[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;249;38;114m-[0m[38;2;190;132;255m1[0m[38;2;248;248;242m)[0m | ||||
| [38;2;248;248;242m    [0m[38;2;248;248;242m{[0m | ||||
| [38;2;248;248;242m        head[0m[38;2;248;248;242m->[0m[38;2;248;248;242mval [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m10[0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m    [0m[38;2;248;248;242m}[0m | ||||
| [38;2;248;248;242m    [0m[38;2;249;38;114melse[0m | ||||
| [38;2;248;248;242m    [0m[38;2;248;248;242m{[0m | ||||
| [38;2;248;248;242m        head[0m[38;2;248;248;242m->[0m[38;2;248;248;242mval [0m[38;2;249;38;114m=[0m[38;2;248;248;242m argc[0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m    [0m[38;2;248;248;242m}[0m | ||||
| [38;2;248;248;242m    [0m[3;38;2;102;217;239mint[0m[38;2;248;248;242m t [0m[38;2;249;38;114m=[0m[38;2;248;248;242m head[0m[38;2;248;248;242m->[0m[38;2;248;248;242mval[0m[38;2;248;248;242m,[0m[38;2;248;248;242m count [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m    [0m[38;2;102;217;239mfree[0m[38;2;248;248;242m([0m[38;2;248;248;242mhead[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m    [0m[38;2;249;38;114mwhile[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mt[0m[38;2;249;38;114m--[0m[38;2;248;248;242m)[0m | ||||
| [38;2;248;248;242m    [0m[38;2;248;248;242m{[0m | ||||
| [38;2;248;248;242m        count[0m[38;2;249;38;114m++[0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m    [0m[38;2;248;248;242m}[0m | ||||
| [38;2;248;248;242m    [0m[38;2;249;38;114mfor[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[3;38;2;102;217;239mint[0m[38;2;248;248;242m i [0m[38;2;249;38;114m=[0m[38;2;248;248;242m t[0m[38;2;248;248;242m;[0m[38;2;248;248;242m i [0m[38;2;249;38;114m<[0m[38;2;248;248;242m count[0m[38;2;248;248;242m;[0m[38;2;248;248;242m [0m[38;2;249;38;114m++[0m[38;2;248;248;242mi[0m[38;2;248;248;242m)[0m | ||||
| [38;2;248;248;242m    [0m[38;2;248;248;242m{[0m | ||||
| [38;2;248;248;242m        [0m[38;2;249;38;114mdo[0m | ||||
| [38;2;248;248;242m        [0m[38;2;248;248;242m{[0m | ||||
| [38;2;248;248;242m            [0m[38;2;249;38;114m--[0m[38;2;248;248;242mcount[0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m        [0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114mwhile[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;190;132;255mfalse[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m    [0m[38;2;248;248;242m}[0m | ||||
| [38;2;248;248;242m    [0m[3;38;2;102;217;239menum[0m[38;2;248;248;242m [0m[38;2;166;226;46mchars[0m | ||||
| [38;2;248;248;242m    [0m[38;2;248;248;242m{[0m | ||||
| [38;2;248;248;242m        M[0m[38;2;248;248;242m,[0m | ||||
| [38;2;248;248;242m        I[0m[38;2;248;248;242m,[0m | ||||
| [38;2;248;248;242m        T[0m[38;2;248;248;242m,[0m | ||||
| [38;2;248;248;242m        H[0m[38;2;248;248;242m,[0m | ||||
| [38;2;248;248;242m        L[0m | ||||
| [38;2;248;248;242m    [0m[38;2;248;248;242m}[0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m    [0m[3;38;2;102;217;239mchar[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242mstring [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mstring[0m[38;2;230;219;116m"[0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m    [0m[38;2;102;217;239mprintf[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mtrue is #define true [0m[38;2;190;132;255m%d[0m[38;2;190;132;255m\n[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255mtrue[0m[38;2;248;248;242m)[0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m    [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m}[0m | ||||
							
								
								
									
										62
									
								
								tests/syntax-tests/source/C/test.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								tests/syntax-tests/source/C/test.c
									
									
									
									
									
										Normal file
									
								
							| @@ -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; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user