Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aevol-eukaryotes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LUISELLI Juliette
aevol-eukaryotes
Commits
1c42a74f
Commit
1c42a74f
authored
1 year ago
by
David Parsons
Browse files
Options
Downloads
Patches
Plain Diff
add tests for Dna_7::subseq
parent
43548812
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/gtest/DnaTest.cpp
+71
-0
71 additions, 0 deletions
test/gtest/DnaTest.cpp
with
71 additions
and
0 deletions
test/gtest/DnaTest.cpp
+
71
−
0
View file @
1c42a74f
...
@@ -35,9 +35,11 @@
...
@@ -35,9 +35,11 @@
#include
<array>
#include
<array>
#include
<memory>
#include
<memory>
#include
<string>
#include
<string>
#include
<sstream>
#include
"Dna_7.h"
#include
"Dna_7.h"
#include
"macros.h"
#include
"macros.h"
#include
"Strand.h"
using
namespace
aevol
;
using
namespace
aevol
;
...
@@ -103,3 +105,72 @@ TEST_F(DnaTest, TestDna) {
...
@@ -103,3 +105,72 @@ TEST_F(DnaTest, TestDna) {
// Check genome size
// Check genome size
EXPECT_EQ
(
genome1
.
size
(),
dna1
->
length
());
EXPECT_EQ
(
genome1
.
size
(),
dna1
->
length
());
}
}
struct
subseq_test_params
{
Strand
strand
;
size_t
first
;
size_t
count
;
bool
spans_oriC
=
false
;
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
subseq_test_params
&
o
)
{
os
<<
"strand: "
<<
o
.
strand
<<
" ; first: "
<<
o
.
first
<<
" ; count: "
<<
o
.
count
<<
" ; spans_oriC: "
<<
(
o
.
spans_oriC
?
"true"
:
"false"
);
return
os
;
}
TEST_F
(
DnaTest
,
Test_subseq
)
{
std
::
array
<
subseq_test_params
,
4
>
tests_leading
=
{{
{
Strand
::
LEADING
,
0
,
10
,
false
},
{
Strand
::
LEADING
,
10
,
42
,
false
},
{
Strand
::
LEADING
,
100
,
42
,
true
},
{
Strand
::
LEADING
,
100
,
genome1
.
size
(),
true
}
// Whole genome
}};
for
(
const
auto
&
test
:
tests_leading
)
{
auto
subseq
=
dna1
->
subseq
(
test
.
first
,
test
.
count
,
test
.
strand
);
// Check subseq size
EXPECT_EQ
(
test
.
count
,
subseq
.
size
());
// Check subseq content
if
(
test
.
spans_oriC
)
{
auto
expected_subseq
=
genome1
.
substr
(
test
.
first
);
expected_subseq
+=
genome1
.
substr
(
0
,
test
.
count
-
expected_subseq
.
size
());
EXPECT_EQ
(
expected_subseq
,
subseq
)
<<
"
\t
Note: testing ("
<<
test
<<
')'
;
}
else
{
EXPECT_EQ
(
genome1
.
substr
(
test
.
first
,
test
.
count
),
subseq
)
<<
"
\t
Note: testing ("
<<
test
<<
')'
;
}
}
std
::
array
<
subseq_test_params
,
3
>
tests_lagging
=
{{
{
Strand
::
LAGGING
,
15
,
12
,
false
},
{
Strand
::
LAGGING
,
genome1
.
size
()
-
1
,
genome1
.
size
(),
false
},
// Whole genome
{
Strand
::
LAGGING
,
4
,
11
,
true
}
}};
for
(
const
auto
&
test
:
tests_lagging
)
{
auto
subseq
=
dna1
->
subseq
(
test
.
first
,
test
.
count
,
test
.
strand
);
// Construct expected result (naïve mode)
std
::
string
expected_subseq
(
test
.
count
,
'0'
);
if
(
test
.
spans_oriC
)
{
for
(
size_t
i
=
0
;
i
<
test
.
first
+
1
;
++
i
)
{
expected_subseq
[
i
]
=
genome1
[
test
.
first
-
i
]
==
'0'
?
'1'
:
'0'
;
}
for
(
size_t
i
=
1
;
i
<
test
.
count
-
test
.
first
;
++
i
)
{
expected_subseq
[
test
.
first
+
i
]
=
genome1
[
genome1
.
size
()
-
i
]
==
'0'
?
'1'
:
'0'
;
}
}
else
{
for
(
size_t
i
=
0
;
i
<
test
.
count
;
++
i
)
{
expected_subseq
[
i
]
=
genome1
[
test
.
first
-
i
]
==
'0'
?
'1'
:
'0'
;
}
}
EXPECT_EQ
(
expected_subseq
,
subseq
)
<<
"
\t
Note: testing ("
<<
test
<<
')'
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment