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();
}
|