2017-02-24 2 views
1

Ich bin neu mit CUnit, ich versuche, einen Beispielcode zu testen, wenn CUnit funktioniert. Ich habe drei Dateien.CUnit Fehler: implizite Erklärung der Funktion 'CU_inizialize_registry'

max.h

#ifndef MAX_H_ 
    #define MAX_H_ 

    extern int maxi(int, int); 

    #endif /* MAX_H_ */ 

max.c

#include "max.h" 

    int maxi (int i1, int i2) 
    { 
     return (i1 > i2) ? i1 : i2; 
    } 

Und Test_max.c

#include <stdio.h> 
    #include <CUnit/CUnit.h> 
    #include <CUnit/Basic.h> 

    #include "max.h" 

    int init_suite(void) 
    { 
     return 0; 
    } 

    int clean_suite(void) 
    { 
     return 0; 
    } 

    void testMax(void) 
    { 
     CU_ASSERT(maxi(1,2) == 2); 
     CU_ASSERT(maxi(3,2) == 3); 
     CU_ASSERT(maxi(2,4) == 4); 
    } 

    int main() 
    { 
     CU_pSuite pSuite = NULL; 

     if (CUE_SUCCESS != CU_inizialize_registry()) 
      return CU_get_error(); 

     pSuite = CU_add_suite("Suite di prova", init_suite, clean_suite); 
     if (NULL == pSuite) 
     { 
      CU_cleanup_registry(); 
      return CU_get_error(); 
     } 

     if (NULL == CU_add_test(pSuite, "Test max", testMax)) 
     { 
      CU_cleanup_registry(); 
      return CU_get_error(); 
     } 

     CU_basic_set_mode(CU_BRM_VERBOSE); 
     CU_basic_run_tests(); 
     CU_cleanup_registry(); 
     return CU_get_error(); 
    } 

Wenn ich bauen erhalte ich eine Warnung und einen Fehler:

  • (warning) warning: implicit declaration of function 'CU_inizialize_registry' is invalid in C99 [-Wimplicit-function-declaration] if (CUE_SUCCESS != CU_inizialize_registry())
  • (error) ld: symbol(s) not found for architecture x86_64

Was ist los mit CU_inizialize_registry? Ich verstehe nicht. Können Sie mir helfen? Dank

Mehr Info: MacOS 10.12.3, Eclipse cunit 2.1-3

Antwort

0

Und was CU_initialize_registry statt CU_iniZialize_registry (t statt z)?

+0

Schande über mich! Ich sah, aber nicht beobachtet. Danke! –

Verwandte Themen