Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simulateDCE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
dj44vuri
simulateDCE
Commits
36cd9c72
Commit
36cd9c72
authored
4 months ago
by
dj44vuri
Browse files
Options
Downloads
Patches
Plain Diff
added tests for readdesign
parent
33c0f758
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/manual-tests/test_idefix.R
+2
-0
2 additions, 0 deletions
tests/manual-tests/test_idefix.R
tests/testthat/test-readdesign.R
+93
-0
93 additions, 0 deletions
tests/testthat/test-readdesign.R
with
95 additions
and
0 deletions
tests/manual-tests/test_idefix.R
+
2
−
0
View file @
36cd9c72
...
...
@@ -19,3 +19,5 @@ identical(t,t2)
design_idefix
<-
system.file
(
"extdata"
,
"Idefix_designs"
,
"test_design2.RDS"
,
package
=
"simulateDCE"
)
t3
<-
readdesign
(
design_idefix
)
c
<-
(
readRDS
(
design_idefix
))
This diff is collapsed.
Click to expand it.
tests/testthat/test-readdesign.R
+
93
−
0
View file @
36cd9c72
...
...
@@ -97,4 +97,97 @@ test_that("all is correct with full idefix objects", {
expect_no_error
(
readdesign
(
design_idefix
,
designtype
=
"idefix"
))
})
#### new tests with kind help from chatgpt
library
(
testthat
)
library
(
simulateDCE
)
test_that
(
"readdesign correctly identifies and processes ngene files"
,
{
# Arrange
design_ngene
<-
system.file
(
"extdata"
,
"agora"
,
"altscf_eff.ngd"
,
package
=
"simulateDCE"
)
# Act
result
<-
readdesign
(
design_ngene
)
# Assert
expect_s3_class
(
result
,
"data.frame"
)
# Check the result is a data frame
expect_true
(
"Choice.situation"
%in%
colnames
(
result
))
# Verify key column presence
# Ensure there are alternative-related columns
alt_columns
<-
colnames
(
result
)[
grepl
(
"^alt"
,
colnames
(
result
))]
expect_gt
(
length
(
alt_columns
),
0
)
# Confirm at least one alt-related column exists
# Validate the structure of the output
expect_gt
(
nrow
(
result
),
0
)
# Ensure the data frame has rows
expect_gt
(
ncol
(
result
),
1
)
# Ensure the data frame has more than one column
expect_message
(
readdesign
(
design_ngene
),
"I guessed it is an ngene file"
)
})
test_that
(
"readdesign correctly identifies and processes spdesign files"
,
{
# Arrange
design_sp
<-
system.file
(
"extdata"
,
"ValuGaps"
,
"des1.RDS"
,
package
=
"simulateDCE"
)
# Act
result_default
<-
readdesign
(
design_sp
)
result_explicit
<-
readdesign
(
design_sp
,
designtype
=
"spdesign"
)
# Assert
expect_s3_class
(
result_default
,
"data.frame"
)
# Check the result is a data frame
expect_s3_class
(
result_explicit
,
"data.frame"
)
expect_identical
(
result_default
,
result_explicit
)
# Default and explicit designtype should match
expect_true
(
"Choice.situation"
%in%
colnames
(
result_default
))
# Verify key column presence
# Ensure there are alternative-related columns
alt_columns
<-
colnames
(
result_default
)[
grepl
(
"^alt"
,
colnames
(
result_default
))]
expect_gt
(
length
(
alt_columns
),
0
)
# Confirm at least one alt-related column exists
# Validate the structure of the output
expect_gt
(
nrow
(
result_default
),
0
)
# Ensure the data frame has rows
expect_gt
(
ncol
(
result_default
),
1
)
# Ensure the data frame has more than one column
expect_message
(
readdesign
(
design_sp
),
"I assume it is a spdesign."
)
})
test_that
(
"readdesign correctly identifies and processes idefix files"
,
{
# Arrange
design_idefix
<-
system.file
(
"extdata"
,
"Idefix_designs"
,
"test_design2.RDS"
,
package
=
"simulateDCE"
)
# Act
result
<-
readdesign
(
design_idefix
)
# Assert
expect_s3_class
(
result
,
"data.frame"
)
# Check the result is a data frame
expect_true
(
"Choice.situation"
%in%
colnames
(
result
))
# Verify key column presence
# Ensure there are alternative-related columns
alt_columns
<-
colnames
(
result
)[
grepl
(
"^alt"
,
colnames
(
result
))]
expect_gt
(
length
(
alt_columns
),
0
)
# Confirm at least one alt-related column exists
# Validate the structure of the output
expect_gt
(
nrow
(
result
),
0
)
# Ensure the data frame has rows
expect_gt
(
ncol
(
result
),
1
)
# Ensure the data frame has more than one column
expect_message
(
readdesign
(
design_idefix
),
"I assume it is an idefix design."
)
})
test_that
(
"readdesign returns a data frame with proper structure"
,
{
# Arrange
design_ngene
<-
system.file
(
"extdata"
,
"agora"
,
"altscf_eff.ngd"
,
package
=
"simulateDCE"
)
# Act
result
<-
readdesign
(
design_ngene
)
# Assert
expect_s3_class
(
result
,
"data.frame"
)
# Check the result is a data frame
expect_true
(
"Choice.situation"
%in%
colnames
(
result
))
# Ensure there are alternative-related columns
alt_columns
<-
colnames
(
result
)[
grepl
(
"^alt"
,
colnames
(
result
))]
expect_gt
(
length
(
alt_columns
),
0
)
# Confirm at least one alt-related column exists
# Validate the structure of the output
expect_gt
(
nrow
(
result
),
0
)
# Ensure the data frame has rows
expect_gt
(
ncol
(
result
),
1
)
# Ensure the data frame has more than one column
})
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