Commit e2aa43c8 authored by Pavel Vainerman's avatar Pavel Vainerman Committed by Pavel Vainerman

(catch2): temp commit

parent 8ea8378f
...@@ -11,6 +11,7 @@ jobs: ...@@ -11,6 +11,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: alt:sisyphus image: alt:sisyphus
options: --privileged
steps: steps:
- name: install packages - name: install packages
run: | run: |
......
...@@ -366,10 +366,13 @@ AC_SUBST(UNISET_EXT_LIBS) ...@@ -366,10 +366,13 @@ AC_SUBST(UNISET_EXT_LIBS)
#AC_LANG_PUSH([C++]) #AC_LANG_PUSH([C++])
#AC_CHECK_HEADERS([catch.hpp],,exit) #AC_CHECK_HEADERS([catch.hpp],,exit)
#AC_LANG_POP([C++]) #AC_LANG_POP([C++])
CATCH_VERSION_MAJOR=1 CATCH_VERSION_MAJOR=1
CATCH_CFLAGS=
CATCH_FILE="include/catch.hpp" CATCH_FILE="include/catch.hpp"
if test ! -e ${CATCH_FILE}; then if test ! -e ${CATCH_FILE}; then
CATCH_FILE="/usr/include/catch.hpp" CATCH_FILE="/usr/include/catch2/catch.hpp"
CATCH_CFLAGS="-I/usr/include/catch2"
fi fi
AC_MSG_CHECKING([catch version in $CATCH_FILE]) AC_MSG_CHECKING([catch version in $CATCH_FILE])
...@@ -485,7 +488,7 @@ CXX_EXTRA_FLAGS="-Wnon-virtual-dtor -Woverloaded-virtual -Woverflow -D_GLIBCXX_U ...@@ -485,7 +488,7 @@ CXX_EXTRA_FLAGS="-Wnon-virtual-dtor -Woverloaded-virtual -Woverflow -D_GLIBCXX_U
# export # export
LDFLAGS="$LDFLAGS ${OMNI_LIBS} ${XML_LIBS} ${SIGC_LIBS} ${COV_LIBS} ${POCO_LIBS} ${EV_LIBS}" LDFLAGS="$LDFLAGS ${OMNI_LIBS} ${XML_LIBS} ${SIGC_LIBS} ${COV_LIBS} ${POCO_LIBS} ${EV_LIBS}"
# all developer liked options add to autogen.sh, please # all developer liked options add to autogen.sh, please
CXXFLAGS="-std=c++17 -I\$(top_builddir)/include $CXXFLAGS -funsigned-char -g -DCATCH_VERSION_MAJOR=${CATCH_VERSION_MAJOR} -D_GNU_SOURCE ${REST_API_CFLAGS} ${COMPORT_485F_CFLAGS} ${OMNI_CFLAGS} ${XML_CFLAGS} ${SIGC_CFLAGS} ${COV_CFLAGS} ${POCO_CFLAGS} ${EV_CFLAGS} $CXX_EXTRA_FLAGS" CXXFLAGS="-I\$(top_builddir)/include $CXXFLAGS ${CATCH_CFLAGS} -funsigned-char -g -D_GNU_SOURCE ${REST_API_CFLAGS} ${COMPORT_485F_CFLAGS} ${OMNI_CFLAGS} ${XML_CFLAGS} ${SIGC_CFLAGS} ${COV_CFLAGS} ${POCO_CFLAGS} ${EV_CFLAGS} $CXX_EXTRA_FLAGS"
AC_SUBST(LDFLAGS) AC_SUBST(LDFLAGS)
AC_SUBST(CXXFLAGS) AC_SUBST(CXXFLAGS)
......
...@@ -28,11 +28,11 @@ int main( int argc, const char* argv[] ) ...@@ -28,11 +28,11 @@ int main( int argc, const char* argv[] )
cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl; cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl;
SharedMemory::help_print(argc, argv); SharedMemory::help_print(argc, argv);
cout << endl << endl << "--------------- CATCH HELP --------------" << endl; cout << endl << endl << "--------------- CATCH HELP --------------" << endl;
session.showHelp("tests_iocontrol"); session.showHelp();
return 0; return 0;
} }
int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore ); int returnCode = session.applyCommandLine( argc, argv );
if( returnCode != 0 ) // Indicates a command line error if( returnCode != 0 ) // Indicates a command line error
return returnCode; return returnCode;
......
...@@ -20,11 +20,11 @@ int main(int argc, const char* argv[] ) ...@@ -20,11 +20,11 @@ int main(int argc, const char* argv[] )
{ {
cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl; cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl;
cout << endl << endl << "--------------- CATCH HELP --------------" << endl; cout << endl << endl << "--------------- CATCH HELP --------------" << endl;
session.showHelp("tests"); session.showHelp();
return 0; return 0;
} }
int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore ); int returnCode = session.applyCommandLine( argc, argv );
if( returnCode != 0 ) // Indicates a command line error if( returnCode != 0 ) // Indicates a command line error
return returnCode; return returnCode;
......
...@@ -27,11 +27,11 @@ int main(int argc, const char* argv[] ) ...@@ -27,11 +27,11 @@ int main(int argc, const char* argv[] )
cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl; cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl;
SharedMemory::help_print(argc, argv); SharedMemory::help_print(argc, argv);
cout << endl << endl << "--------------- CATCH HELP --------------" << endl; cout << endl << endl << "--------------- CATCH HELP --------------" << endl;
session.showHelp("tests"); session.showHelp();
return 0; return 0;
} }
int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore ); int returnCode = session.applyCommandLine( argc, argv );
if( returnCode != 0 ) // Indicates a command line error if( returnCode != 0 ) // Indicates a command line error
return returnCode; return returnCode;
......
...@@ -24,11 +24,11 @@ int main(int argc, const char* argv[] ) ...@@ -24,11 +24,11 @@ int main(int argc, const char* argv[] )
cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl; cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl;
SharedMemory::help_print(argc, argv); SharedMemory::help_print(argc, argv);
cout << endl << endl << "--------------- CATCH HELP --------------" << endl; cout << endl << endl << "--------------- CATCH HELP --------------" << endl;
session.showHelp("test_multicast_with_sm"); session.showHelp();
return 0; return 0;
} }
int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore ); int returnCode = session.applyCommandLine( argc, argv );
if( returnCode != 0 ) // Indicates a command line error if( returnCode != 0 ) // Indicates a command line error
return returnCode; return returnCode;
......
...@@ -24,11 +24,11 @@ int main(int argc, const char* argv[] ) ...@@ -24,11 +24,11 @@ int main(int argc, const char* argv[] )
cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl; cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl;
SharedMemory::help_print(argc, argv); SharedMemory::help_print(argc, argv);
cout << endl << endl << "--------------- CATCH HELP --------------" << endl; cout << endl << endl << "--------------- CATCH HELP --------------" << endl;
session.showHelp("test_with_sm"); session.showHelp();
return 0; return 0;
} }
int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore ); int returnCode = session.applyCommandLine( argc, argv );
if( returnCode != 0 ) // Indicates a command line error if( returnCode != 0 ) // Indicates a command line error
return returnCode; return returnCode;
......
...@@ -286,6 +286,11 @@ namespace uniset ...@@ -286,6 +286,11 @@ namespace uniset
{ {
return raw; return raw;
} }
// ------------------------------------------
operator int()
{
return raw;
}
uint16_t raw; uint16_t raw;
}; };
...@@ -325,6 +330,10 @@ namespace uniset ...@@ -325,6 +330,10 @@ namespace uniset
{ {
return raw; return raw;
} }
operator int()
{
return raw;
}
int16_t raw; int16_t raw;
}; };
......
...@@ -319,13 +319,13 @@ TEST_CASE("VTypes: Signed", "[vtypes][signed]") ...@@ -319,13 +319,13 @@ TEST_CASE("VTypes: Signed", "[vtypes][signed]")
{ {
long l = -32766; long l = -32766;
Signed v(l); Signed v(l);
REQUIRE( (int16_t)v == l ); REQUIRE( v == l );
} }
SECTION("Modbus constructor") SECTION("Modbus constructor")
{ {
ModbusRTU::ModbusData d = 65535; ModbusRTU::ModbusData d = 65535;
Signed v(d); Signed v(d);
REQUIRE( (int16_t)v == (int16_t)d ); REQUIRE( (int)v == (int)d );
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -54,11 +54,11 @@ int main(int argc, const char* argv[] ) ...@@ -54,11 +54,11 @@ int main(int argc, const char* argv[] )
cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl; cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl;
SharedMemory::help_print(argc, argv); SharedMemory::help_print(argc, argv);
cout << endl << endl << "--------------- CATCH HELP --------------" << endl; cout << endl << endl << "--------------- CATCH HELP --------------" << endl;
session.showHelp("test_with_sm"); session.showHelp();
return 0; return 0;
} }
int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore ); int returnCode = session.applyCommandLine( argc, argv );
if( returnCode != 0 ) // Indicates a command line error if( returnCode != 0 ) // Indicates a command line error
return returnCode; return returnCode;
......
...@@ -86,7 +86,7 @@ TEST_CASE( "Configuration", "[Configuration]" ) ...@@ -86,7 +86,7 @@ TEST_CASE( "Configuration", "[Configuration]" )
{ {
int t_argc = 0; int t_argc = 0;
char t_argv[] = {""}; char t_argv[] = {""};
REQUIRE_THROWS_AS( Configuration(t_argc, (const char* const*)(t_argv), ""), uniset::SystemError& ); REQUIRE_THROWS_AS( Configuration(t_argc, (const char* const*)(t_argv), ""), uniset::SystemError );
} }
// SECTION( "ObjectIndex Constructor" ) // SECTION( "ObjectIndex Constructor" )
...@@ -98,7 +98,7 @@ TEST_CASE( "Configuration", "[Configuration]" ) ...@@ -98,7 +98,7 @@ TEST_CASE( "Configuration", "[Configuration]" )
int t_argc = 0; int t_argc = 0;
char t_argv[] = {""}; char t_argv[] = {""};
ulog()->level(Debug::NONE); ulog()->level(Debug::NONE);
REQUIRE_THROWS_AS( Configuration(t_argc, (const char* const*)(t_argv), "tests_no_objectsmap.xml"), uniset::SystemError& ); REQUIRE_THROWS_AS( Configuration(t_argc, (const char* const*)(t_argv), "tests_no_objectsmap.xml"), uniset::SystemError );
} }
SECTION( "Bad conf: no <UniSet>" ) SECTION( "Bad conf: no <UniSet>" )
...@@ -106,7 +106,7 @@ TEST_CASE( "Configuration", "[Configuration]" ) ...@@ -106,7 +106,7 @@ TEST_CASE( "Configuration", "[Configuration]" )
int t_argc = 0; int t_argc = 0;
char t_argv[] = {""}; char t_argv[] = {""};
ulog()->level(Debug::NONE); ulog()->level(Debug::NONE);
REQUIRE_THROWS_AS( Configuration(t_argc, (const char* const*)(t_argv), "tests_no_uniset_section.xml"), uniset::SystemError& ); REQUIRE_THROWS_AS( Configuration(t_argc, (const char* const*)(t_argv), "tests_no_uniset_section.xml"), uniset::SystemError );
} }
} }
...@@ -19,5 +19,5 @@ TEST_CASE("ObjectIndexHash", "[oindex_hash][basic]" ) ...@@ -19,5 +19,5 @@ TEST_CASE("ObjectIndexHash", "[oindex_hash][basic]" )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
TEST_CASE("ObjectIndexHash: collision", "[oindex_hash][base][collision]" ) TEST_CASE("ObjectIndexHash: collision", "[oindex_hash][base][collision]" )
{ {
REQUIRE_THROWS_AS( ObjectIndex_hashXML("tests_oindex_hash_collision_config.xml"), uniset::SystemError& ); REQUIRE_THROWS_AS( ObjectIndex_hashXML("tests_oindex_hash_collision_config.xml"), uniset::SystemError );
} }
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <atomic> #include <atomic>
#include <future> #include <future>
#include <ostream> #include <ostream>
#include <sstream>
#include "UTCPSocket.h" #include "UTCPSocket.h"
#include "TCPCheck.h" #include "TCPCheck.h"
...@@ -61,7 +62,7 @@ TEST_CASE("TCPCheck::check", "[tcpcheck][tcpcheck_check]" ) ...@@ -61,7 +62,7 @@ TEST_CASE("TCPCheck::check", "[tcpcheck][tcpcheck_check]" )
TCPCheck t; TCPCheck t;
TSRunner tserv; TSRunner tserv;
ostringstream ia; std::ostringstream ia;
ia << host << ":" << port; ia << host << ":" << port;
msleep(200); msleep(200);
......
...@@ -27,25 +27,25 @@ TEST_CASE("UInterface", "[UInterface]") ...@@ -27,25 +27,25 @@ TEST_CASE("UInterface", "[UInterface]")
CHECK( ui.getConfIOType(sid) != UniversalIO::UnknownIOType ); CHECK( ui.getConfIOType(sid) != UniversalIO::UnknownIOType );
REQUIRE_THROWS_AS( ui.getValue(DefaultObjectId), uniset::ORepFailed& ); REQUIRE_THROWS_AS( ui.getValue(DefaultObjectId), uniset::ORepFailed );
REQUIRE_THROWS_AS( ui.getValue(sid), uniset::Exception& ); REQUIRE_THROWS_AS( ui.getValue(sid), uniset::Exception );
REQUIRE_THROWS_AS( ui.getValue(sid, DefaultObjectId), uniset::Exception& ); REQUIRE_THROWS_AS( ui.getValue(sid, DefaultObjectId), uniset::Exception );
REQUIRE_THROWS_AS( ui.getValue(sid, 100), uniset::Exception& ); REQUIRE_THROWS_AS( ui.getValue(sid, 100), uniset::Exception );
REQUIRE_THROWS_AS( ui.resolve(sid), uniset::ORepFailed& ); REQUIRE_THROWS_AS( ui.resolve(sid), uniset::ORepFailed );
REQUIRE_THROWS_AS( ui.resolve(sid, 10), uniset::ResolveNameError& ); REQUIRE_THROWS_AS( ui.resolve(sid, 10), uniset::ResolveNameError );
REQUIRE_THROWS_AS( ui.resolve(sid, DefaultObjectId), ResolveNameError& ); REQUIRE_THROWS_AS( ui.resolve(sid, DefaultObjectId), ResolveNameError );
TransportMessage tm( SensorMessage(sid, 10).transport_msg() ); TransportMessage tm( SensorMessage(sid, 10).transport_msg() );
REQUIRE_THROWS_AS( ui.send(testOID, tm), uniset::Exception& ); REQUIRE_THROWS_AS( ui.send(testOID, tm), uniset::Exception );
REQUIRE_THROWS_AS( ui.send(testOID, tm, -20), uniset::Exception& ); REQUIRE_THROWS_AS( ui.send(testOID, tm, -20), uniset::Exception );
REQUIRE_THROWS_AS( ui.send(testOID, tm, DefaultObjectId), uniset::Exception& ); REQUIRE_THROWS_AS( ui.send(testOID, tm, DefaultObjectId), uniset::Exception );
REQUIRE_THROWS_AS( ui.getTimeChange(sid, -20), uniset::Exception& ); REQUIRE_THROWS_AS( ui.getTimeChange(sid, -20), uniset::Exception );
REQUIRE_THROWS_AS( ui.getTimeChange(sid, DefaultObjectId), uniset::Exception& ); REQUIRE_THROWS_AS( ui.getTimeChange(sid, DefaultObjectId), uniset::Exception );
REQUIRE_THROWS_AS( ui.getTimeChange(sid, conf->getLocalNode()), uniset::Exception& ); REQUIRE_THROWS_AS( ui.getTimeChange(sid, conf->getLocalNode()), uniset::Exception );
REQUIRE_THROWS_AS( ui.sendText(testOID, "hello", 1), uniset::Exception& ); REQUIRE_THROWS_AS( ui.sendText(testOID, "hello", 1), uniset::Exception );
REQUIRE_THROWS_AS( ui.sendText(testOID, "hello", 1, -20), uniset::Exception& ); REQUIRE_THROWS_AS( ui.sendText(testOID, "hello", 1, -20), uniset::Exception );
CHECK_FALSE( ui.isExist(sid) ); CHECK_FALSE( ui.isExist(sid) );
CHECK_FALSE( ui.isExist(sid, DefaultObjectId) ); CHECK_FALSE( ui.isExist(sid, DefaultObjectId) );
......
...@@ -20,8 +20,8 @@ TEST_CASE("UniXML", "[unixml][basic]" ) ...@@ -20,8 +20,8 @@ TEST_CASE("UniXML", "[unixml][basic]" )
SECTION( "Bad file" ) SECTION( "Bad file" )
{ {
REQUIRE_THROWS_AS( UniXML("unknown.xml"), uniset::NameNotFound& ); REQUIRE_THROWS_AS( UniXML("unknown.xml"), uniset::NameNotFound );
REQUIRE_THROWS_AS( UniXML("tests_unixml_badfile.xml"), uniset::Exception& ); REQUIRE_THROWS_AS( UniXML("tests_unixml_badfile.xml"), uniset::Exception );
} }
UniXML uxml("tests_unixml.xml"); UniXML uxml("tests_unixml.xml");
...@@ -234,6 +234,6 @@ TEST_CASE("UniXML createFromText", "[unixml][createFromText]" ) ...@@ -234,6 +234,6 @@ TEST_CASE("UniXML createFromText", "[unixml][createFromText]" )
CHECK_FALSE( uxml.isOpen() ); CHECK_FALSE( uxml.isOpen() );
const string badtext = "<?xml version="; const string badtext = "<?xml version=";
REQUIRE_THROWS_AS(uxml.createFromText(badtext), uniset::SystemError& ); REQUIRE_THROWS_AS(uxml.createFromText(badtext), uniset::SystemError );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -13,7 +13,7 @@ int main( int argc, const char* argv[] ) ...@@ -13,7 +13,7 @@ int main( int argc, const char* argv[] )
uniset::uniset_init(argc, argv); uniset::uniset_init(argc, argv);
int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore ); int returnCode = session.applyCommandLine( argc, argv );
if( returnCode != 0 ) // Indicates a command line error if( returnCode != 0 ) // Indicates a command line error
return returnCode; return returnCode;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment