github.com/Konstantin8105/c4go@v0.0.0-20240505174241-768bb1c65a51/tests/argv.c (about) 1 // This file contains tests for the system arguments (argv). 2 3 #include "tests.h" 4 #include <stdio.h> 5 6 int main(int argc, const char** argv) 7 { 8 plan(2); 9 10 // When this file is converted to go it is run through "go test" that needs 11 // some extra arguments before the standard C arguments. We need to adjust 12 // an offset so that the C program and the Go program read the same index 13 // for the first index of the real arguments. 14 int offset = 0; 15 16 // More than three arguments means it must be run under "go test". If not 17 // the assertion immediately below will fail. 18 if (argc > 3) { 19 offset = argc - 3; 20 } 21 22 // We cannot compare the zeroth argument because it will be different for C 23 // and Go. 24 // is_streq(argv[0], "build/go.out"); 25 26 is_streq(argv[1 + offset], "some"); 27 is_streq(argv[2 + offset], "args"); 28 29 int os = 9; 30 (void)(os); 31 32 done_testing(); 33 } 34 35 void os() {}