-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tests] Добавление тестов для менеджера рецептов (#779)
Co-authored-by: Dzmitry Ivaniuk <dzimitriy@gmail.com>
- Loading branch information
Showing
9 changed files
with
315 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,68 @@ | ||
#include "g_device_tests.h" | ||
#include "tcp_cmctr.h" | ||
#include "lua_manager.h" | ||
#include "device/manager.h" | ||
|
||
using namespace ::testing; | ||
|
||
|
||
TEST( device_communicator, write_devices_states_service ) | ||
{ | ||
auto L = lua_open(); | ||
G_LUA_MANAGER->set_Lua( L ); | ||
|
||
const int IN_BUFF_SIZE = 100; | ||
const int OUT_BUFF_SIZE = 1000; | ||
unsigned char data[ IN_BUFF_SIZE ] = { '\0' }; | ||
unsigned char data[ IN_BUFF_SIZE ] = { '\0' }; | ||
auto cmd_size = 1; | ||
unsigned char out_data[ OUT_BUFF_SIZE ] = { '\0' }; | ||
|
||
tcp_communicator::init_instance( "Тест", "Test" ); | ||
|
||
device_communicator::switch_on_compression(); | ||
|
||
data[0] = device_communicator::CMD_GET_INFO_ON_CONNECT; | ||
device_communicator::write_devices_states_service(0, data, out_data); | ||
EXPECT_EQ('\0', out_data[0]); | ||
|
||
data[ 0 ] = device_communicator::CMD_GET_INFO_ON_CONNECT; | ||
G_DEVICE_CMMCTR->write_devices_states_service( cmd_size, data, out_data ); | ||
device_communicator::write_devices_states_service( cmd_size, data, out_data ); | ||
EXPECT_EQ( 'x', out_data[ 0 ] ); | ||
|
||
data[ 0 ] = device_communicator::CMD_GET_DEVICES; | ||
G_DEVICE_CMMCTR->write_devices_states_service( cmd_size, data, out_data ); | ||
device_communicator::write_devices_states_service( cmd_size, data, out_data ); | ||
EXPECT_EQ( 'x', out_data[ 0 ] ); | ||
|
||
data[ 0 ] = device_communicator::CMD_GET_DEVICES_STATES; | ||
G_DEVICE_CMMCTR->write_devices_states_service( cmd_size, data, out_data ); | ||
device_communicator::write_devices_states_service( cmd_size, data, out_data ); | ||
EXPECT_EQ( 'x', out_data[ 0 ] ); | ||
|
||
data[ 0 ] = device_communicator::CMD_GET_PAC_ERRORS; | ||
G_DEVICE_CMMCTR->write_devices_states_service( cmd_size, data, out_data ); | ||
device_communicator::write_devices_states_service( cmd_size, data, out_data ); | ||
EXPECT_EQ( 'x', out_data[ 0 ] ); | ||
|
||
data[ 0 ] = device_communicator::CMD_EXEC_DEVICE_COMMAND; | ||
device_communicator::write_devices_states_service( cmd_size, data, out_data ); | ||
EXPECT_EQ( 'x', out_data[ 0 ] ); | ||
|
||
unsigned char recman_data[IN_BUFF_SIZE] = " __RECMAN[1]:set_cmd( \"hello\", 1, 2.5 )"; | ||
recman_data[0] = device_communicator::CMD_EXEC_DEVICE_COMMAND; | ||
device_communicator::write_devices_states_service(cmd_size, recman_data, out_data); | ||
EXPECT_EQ('x', out_data[0]); | ||
|
||
G_LUA_MANAGER->free_Lua(); | ||
} | ||
|
||
TEST( device_communicator, print ) | ||
{ | ||
G_DEVICE_MANAGER()->clear_io_devices(); | ||
|
||
std::string STR_check = R"(Device communicator. Dev count = 1. | ||
[ 0 ] Device manager | ||
)"; | ||
testing::internal::CaptureStdout(); | ||
G_DEVICE_CMMCTR->print(); | ||
auto output = testing::internal::GetCapturedStdout(); | ||
EXPECT_EQ( output, STR_check ); | ||
EXPECT_TRUE( true ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.