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

(catch2): temp commit

parent 8ea8378f
......@@ -11,6 +11,7 @@ jobs:
runs-on: ubuntu-latest
container:
image: alt:sisyphus
options: --privileged
steps:
- name: install packages
run: |
......
......@@ -366,10 +366,13 @@ AC_SUBST(UNISET_EXT_LIBS)
#AC_LANG_PUSH([C++])
#AC_CHECK_HEADERS([catch.hpp],,exit)
#AC_LANG_POP([C++])
CATCH_VERSION_MAJOR=1
CATCH_CFLAGS=
CATCH_FILE="include/catch.hpp"
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
AC_MSG_CHECKING([catch version in $CATCH_FILE])
......@@ -485,7 +488,7 @@ CXX_EXTRA_FLAGS="-Wnon-virtual-dtor -Woverloaded-virtual -Woverflow -D_GLIBCXX_U
# export
LDFLAGS="$LDFLAGS ${OMNI_LIBS} ${XML_LIBS} ${SIGC_LIBS} ${COV_LIBS} ${POCO_LIBS} ${EV_LIBS}"
# 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(CXXFLAGS)
......
......@@ -28,11 +28,11 @@ int main( int argc, const char* argv[] )
cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl;
SharedMemory::help_print(argc, argv);
cout << endl << endl << "--------------- CATCH HELP --------------" << endl;
session.showHelp("tests_iocontrol");
session.showHelp();
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
return returnCode;
......
......@@ -20,11 +20,11 @@ int main(int argc, const char* argv[] )
{
cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl;
cout << endl << endl << "--------------- CATCH HELP --------------" << endl;
session.showHelp("tests");
session.showHelp();
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
return returnCode;
......
......@@ -27,11 +27,11 @@ int main(int argc, const char* argv[] )
cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl;
SharedMemory::help_print(argc, argv);
cout << endl << endl << "--------------- CATCH HELP --------------" << endl;
session.showHelp("tests");
session.showHelp();
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
return returnCode;
......
......@@ -24,11 +24,11 @@ int main(int argc, const char* argv[] )
cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl;
SharedMemory::help_print(argc, argv);
cout << endl << endl << "--------------- CATCH HELP --------------" << endl;
session.showHelp("test_multicast_with_sm");
session.showHelp();
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
return returnCode;
......
......@@ -24,11 +24,11 @@ int main(int argc, const char* argv[] )
cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl;
SharedMemory::help_print(argc, argv);
cout << endl << endl << "--------------- CATCH HELP --------------" << endl;
session.showHelp("test_with_sm");
session.showHelp();
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
return returnCode;
......
......@@ -286,6 +286,11 @@ namespace uniset
{
return raw;
}
// ------------------------------------------
operator int()
{
return raw;
}
uint16_t raw;
};
......@@ -325,6 +330,10 @@ namespace uniset
{
return raw;
}
operator int()
{
return raw;
}
int16_t raw;
};
......
......@@ -319,13 +319,13 @@ TEST_CASE("VTypes: Signed", "[vtypes][signed]")
{
long l = -32766;
Signed v(l);
REQUIRE( (int16_t)v == l );
REQUIRE( v == l );
}
SECTION("Modbus constructor")
{
ModbusRTU::ModbusData d = 65535;
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[] )
cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl;
SharedMemory::help_print(argc, argv);
cout << endl << endl << "--------------- CATCH HELP --------------" << endl;
session.showHelp("test_with_sm");
session.showHelp();
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
return returnCode;
......
......@@ -86,7 +86,7 @@ TEST_CASE( "Configuration", "[Configuration]" )
{
int t_argc = 0;
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" )
......@@ -98,7 +98,7 @@ TEST_CASE( "Configuration", "[Configuration]" )
int t_argc = 0;
char t_argv[] = {""};
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>" )
......@@ -106,7 +106,7 @@ TEST_CASE( "Configuration", "[Configuration]" )
int t_argc = 0;
char t_argv[] = {""};
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]" )
// -----------------------------------------------------------------------------
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 @@
#include <atomic>
#include <future>
#include <ostream>
#include <sstream>
#include "UTCPSocket.h"
#include "TCPCheck.h"
......@@ -61,7 +62,7 @@ TEST_CASE("TCPCheck::check", "[tcpcheck][tcpcheck_check]" )
TCPCheck t;
TSRunner tserv;
ostringstream ia;
std::ostringstream ia;
ia << host << ":" << port;
msleep(200);
......
......@@ -27,25 +27,25 @@ TEST_CASE("UInterface", "[UInterface]")
CHECK( ui.getConfIOType(sid) != UniversalIO::UnknownIOType );
REQUIRE_THROWS_AS( ui.getValue(DefaultObjectId), uniset::ORepFailed& );
REQUIRE_THROWS_AS( ui.getValue(sid), 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(DefaultObjectId), uniset::ORepFailed );
REQUIRE_THROWS_AS( ui.getValue(sid), uniset::Exception );
REQUIRE_THROWS_AS( ui.getValue(sid, DefaultObjectId), 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, 10), uniset::ResolveNameError& );
REQUIRE_THROWS_AS( ui.resolve(sid, DefaultObjectId), ResolveNameError& );
REQUIRE_THROWS_AS( ui.resolve(sid), uniset::ORepFailed );
REQUIRE_THROWS_AS( ui.resolve(sid, 10), uniset::ResolveNameError );
REQUIRE_THROWS_AS( ui.resolve(sid, DefaultObjectId), ResolveNameError );
TransportMessage tm( SensorMessage(sid, 10).transport_msg() );
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, DefaultObjectId), 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, conf->getLocalNode()), 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.send(testOID, tm), 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.getTimeChange(sid, -20), 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.sendText(testOID, "hello", 1), uniset::Exception );
REQUIRE_THROWS_AS( ui.sendText(testOID, "hello", 1, -20), uniset::Exception );
CHECK_FALSE( ui.isExist(sid) );
CHECK_FALSE( ui.isExist(sid, DefaultObjectId) );
......
......@@ -20,8 +20,8 @@ TEST_CASE("UniXML", "[unixml][basic]" )
SECTION( "Bad file" )
{
REQUIRE_THROWS_AS( UniXML("unknown.xml"), uniset::NameNotFound& );
REQUIRE_THROWS_AS( UniXML("tests_unixml_badfile.xml"), uniset::Exception& );
REQUIRE_THROWS_AS( UniXML("unknown.xml"), uniset::NameNotFound );
REQUIRE_THROWS_AS( UniXML("tests_unixml_badfile.xml"), uniset::Exception );
}
UniXML uxml("tests_unixml.xml");
......@@ -234,6 +234,6 @@ TEST_CASE("UniXML createFromText", "[unixml][createFromText]" )
CHECK_FALSE( uxml.isOpen() );
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[] )
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
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