Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
f755d8be
Commit
f755d8be
authored
Sep 05, 2017
by
Ronan
Browse files
feat(tests): add a clonable object test
parent
76c884ab
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/object/clonable-object-p.h
View file @
f755d8be
...
...
@@ -29,6 +29,7 @@ LINPHONE_BEGIN_NAMESPACE
class
ClonableObjectPrivate
{
public:
ClonableObjectPrivate
()
=
default
;
virtual
~
ClonableObjectPrivate
()
=
default
;
protected:
...
...
@@ -41,6 +42,10 @@ private:
int
nRefs
=
0
;
L_DECLARE_PUBLIC
(
ClonableObject
);
// It's forbidden to copy directly one Clonable object private.
// To allow copy, you must define copy constructor in inherited object.
L_DISABLE_COPY
(
ClonableObjectPrivate
);
};
LINPHONE_END_NAMESPACE
...
...
src/object/clonable-object.cpp
View file @
f755d8be
...
...
@@ -45,7 +45,7 @@ ClonableObject::ClonableObject (ClonableObjectPrivate &p) : mPrivate(&p) {
// Q-pointer must be empty. It's a constructor that takes a new private data.
L_ASSERT
(
!
mPrivate
->
mPublic
);
mPrivate
->
mPublic
=
new
remove_pointer
<
decltype
(
mPrivate
->
mPublic
)
>::
type
;
mPrivate
->
mPublic
=
new
remove_pointer
<
decltype
(
mPrivate
->
mPublic
)
>::
type
()
;
(
*
mPrivate
->
mPublic
)[
mPrivate
]
=
this
;
mPrivate
->
ref
();
}
...
...
tester/CMakeLists.txt
View file @
f755d8be
...
...
@@ -193,6 +193,7 @@ set(SOURCE_FILES_C
)
set
(
SOURCE_FILES_CXX
clonable-object-tester.cpp
cpim-tester.cpp
)
...
...
tester/clonable-object-tester.cpp
0 → 100644
View file @
f755d8be
/*
* clonable-object-tester.cpp
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 "object/clonable-object-p.h"
#include "object/clonable-object.h"
#include "liblinphone_tester.h"
// =============================================================================
using
namespace
std
;
using
namespace
LinphonePrivate
;
// -----------------------------------------------------------------------------
class
TestObjectPrivate
:
public
ClonableObjectPrivate
{
public:
TestObjectPrivate
()
=
default
;
TestObjectPrivate
(
const
TestObjectPrivate
&
)
:
TestObjectPrivate
()
{}
};
class
TestObject
:
public
ClonableObject
{
public:
TestObject
()
:
ClonableObject
(
*
new
TestObjectPrivate
)
{}
TestObject
(
const
TestObject
&
src
)
:
ClonableObject
(
*
new
TestObjectPrivate
(
*
src
.
getPrivate
()))
{}
private:
L_DECLARE_PRIVATE
(
TestObject
);
};
// -----------------------------------------------------------------------------
static
void
check_clonable_object_creation
()
{
TestObject
*
object
=
new
TestObject
();
TestObject
*
object2
=
new
TestObject
(
*
object
);
delete
object
;
delete
object2
;
}
test_t
clonable_object_tests
[]
=
{
TEST_NO_TAG
(
"Check clonable object creation"
,
check_clonable_object_creation
)
};
test_suite_t
clonable_object_test_suite
=
{
"ClonableObject"
,
NULL
,
NULL
,
liblinphone_tester_before_each
,
liblinphone_tester_after_each
,
sizeof
(
clonable_object_tests
)
/
sizeof
(
clonable_object_tests
[
0
]),
clonable_object_tests
};
tester/liblinphone_tester.h
View file @
f755d8be
...
...
@@ -42,6 +42,7 @@ extern "C" {
extern
test_suite_t
account_creator_test_suite
;
extern
test_suite_t
call_test_suite
;
extern
test_suite_t
call_video_test_suite
;
extern
test_suite_t
clonable_object_test_suite
;
extern
test_suite_t
cpim_test_suite
;
extern
test_suite_t
dtmf_test_suite
;
extern
test_suite_t
event_test_suite
;
...
...
tester/tester.c
View file @
f755d8be
...
...
@@ -574,6 +574,7 @@ void liblinphone_tester_add_suites() {
bc_tester_add_suite
(
&
player_test_suite
);
bc_tester_add_suite
(
&
dtmf_test_suite
);
bc_tester_add_suite
(
&
cpim_test_suite
);
bc_tester_add_suite
(
&
clonable_object_test_suite
);
#if defined(VIDEO_ENABLED) && defined(HAVE_GTK)
bc_tester_add_suite
(
&
video_test_suite
);
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment