File: argv.c

package info (click to toggle)
c2go 0.26.11-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,052 kB
  • sloc: ansic: 6,037; sh: 82; makefile: 5
file content (30 lines) | stat: -rw-r--r-- 879 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// This file contains tests for the system arguments (argv).

#include <stdio.h>
#include "tests.h"

int main(int argc, const char **argv)
{
    plan(2);

    // When this file is converted to go it is run through "go test" that needs
    // some extra arguments before the standard C arguments. We need to adjust
    // an offset so that the C program and the Go program read the same index
    // for the first index of the real arguments.
    int offset = 0;

    // More than three arguments means it must be run under "go test". If not
    // the assertion immediately below will fail.
    if (argc > 3) {
        offset = 3;
    }

    // We cannot compare the zeroth argument because it will be different for C
    // and Go.
    // is_streq(argv[0], "build/go.out");

    is_streq(argv[1 + offset], "some");
    is_streq(argv[2 + offset], "args");

    done_testing();
}