a few tests

This commit is contained in:
Ignacio Rodriguez
2020-11-03 22:31:50 +07:00
parent 77ee71768b
commit edbf4dfeda
4 changed files with 95 additions and 1 deletions

14
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "unittests",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/unittests"
}
]
}

25
.vscode/settings.json vendored
View File

@ -6,5 +6,28 @@
"xevent",
"xscreensaver",
"xscreensaver's"
]
],
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "googletest.failed",
"settings": {
"foreground": "#f00"
}
},
{
"scope": "googletest.passed",
"settings": {
"foreground": "#0f0"
}
},
{
"scope": "googletest.run",
"settings": {
"foreground": "#0f0"
}
}
]
},
"gtest-adapter.supportLocation": true
}

View File

@ -0,0 +1,49 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "synergy/ArgParser.h"
#include "synergy/ServerArgs.h"
#define TEST_ENV
#include "synergy/ServerApp.h"
#include "test/global/gmock.h"
class MockServerApp : public ServerApp
{
public:
MockServerApp() : ServerApp(nullptr, nullptr) { }
};
#include "test/global/gtest.h"
// using ::testing::_;
// using ::testing::Invoke;
using ::testing::NiceMock;
TEST(ServerAppTests, runInner_will_handle_configuration_lifetime)
{
NiceMock<MockServerApp> app;
EXPECT_FALSE(app.args().m_config);
const char *argv[] {"synergyc"};
app.runInner(1, const_cast<char **>(argv), nullptr, [](int,char**){ return 0; });
EXPECT_TRUE(app.args().m_config);
}

View File

@ -37,6 +37,14 @@ server_stubCheckUnexpectedArgs()
return false;
}
TEST(ServerArgs, ServerArgs_will_construct_from_copy)
{
lib::synergy::ServerArgs serverArgs;
serverArgs.m_display = "display0";
auto serverArgs2 {serverArgs};
EXPECT_EQ(serverArgs.m_display, serverArgs2.m_display);
}
TEST(ServerArgsParsingTests, parseServerArgs_addressArg_setSynergyAddress)
{
NiceMock<MockArgParser> argParser;