mirror of https://github.com/CGAL/cgal
Add a test for LEDA
When LEDA is available, that test program tests very basic I/O operations of `leda::rational`. That also tests the link with LEDA.
This commit is contained in:
parent
bb2b50427c
commit
3ae8979318
|
|
@ -44,7 +44,7 @@ if ( CGAL_FOUND )
|
|||
|
||||
create_single_source_cgal_program( "test_use_h.cpp" )
|
||||
|
||||
find_package( TBB )
|
||||
find_package( TBB QUIET )
|
||||
if( TBB_FOUND )
|
||||
include(${TBB_USE_FILE})
|
||||
list(APPEND CGAL_3RD_PARTY_LIBRARIES ${TBB_LIBRARIES})
|
||||
|
|
@ -77,7 +77,14 @@ if ( CGAL_FOUND )
|
|||
add_executable(test_gmp_mpfr_dll test_gmp_mpfr_dll.cpp)
|
||||
target_link_libraries(test_gmp_mpfr_dll Version)
|
||||
endif(WIN32)
|
||||
|
||||
|
||||
find_package( LEDA QUIET)
|
||||
if(LEDA_FOUND)
|
||||
include( ${LEDA_USE_FILE} )
|
||||
add_executable(test_LEDA_IO test_LEDA_IO.cpp)
|
||||
target_link_libraries(test_LEDA_IO ${LEDA_LIBRARIES})
|
||||
endif()
|
||||
|
||||
else()
|
||||
|
||||
message(STATUS "NOTICE: This program requires the CGAL library, and will not be compiled.")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
#include <LEDA/numbers/rational.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
const char* tests[] = { "0\n", "1/2\n", "3 4", "0", "1/2" };
|
||||
|
||||
int main()
|
||||
{
|
||||
for(int i = 0, end = sizeof(tests)/sizeof(char*);
|
||||
i < end; ++i)
|
||||
{
|
||||
std::cout << "input: \"" << tests[i] << "\"\n";
|
||||
std::stringstream input(tests[i]); // no \n: EOF instead
|
||||
leda::rational a;
|
||||
input >> a;
|
||||
if(!input.fail()) {
|
||||
std::cout << "a is " << a << std::endl;
|
||||
if(std::cout.fail()) {
|
||||
std::cerr << "std::count.fail() is set!\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
std::cerr << "input.fail() is set!\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Loading…
Reference in New Issue