在C中测试Dominion Card游戏

时间:2016-01-31 02:16:03

标签: c testing

我被要求在纸牌游戏领域的4个功能上编写测试程序。我写了一篇(非常简单)只是为了确保我能够通过,因为我对测试很陌生。但是,我不断在运行时遇到语法错误,我无法弄清楚。

    #include <stdlib.h>
    #include <stdio.h>
    #include <assert.h>
    #include "dominion.h"
    #include "dominion_helpers.h"
    #include "rngs.h"

    int main() {
        int r = 0, j = 0;
        int adventurer = 8;
        int greathall = 17;

        r = getCost(adventurer);
        assert(r == 6);

        j = getCost(greathall);
        assert(j == 3);

        return 0;
    }

当我编译它时,我会收到一些警告:

    Undefined symbols for architecture x86_64:
      "_getCost", referenced from:
          _main in unittest1-7d7bf2.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

我也不确定,但我们教师提供的基本代码以及同学的所有其他代码也有这些警告。

但是,在运行时我收到以下错误:

    ./unittest1.c: line 8: syntax error near unexpected token `('
    ./unittest1.c: line 8: `int main() {'

我尝试在一个空白文件中重写它,认为有一些看不见的字符或其他东西,但我仍然得到这个错误。有没有人在我的代码中看到错误?任何帮助表示赞赏。

**在dominion_helpers中调用getCost

0 个答案:

没有答案