Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
5304885c
"vscode:/vscode.git/clone" did not exist on "015c8fff7203b7266ce187938327bc7b478a7218"
Unverified
Commit
5304885c
authored
Apr 24, 2020
by
James Lamb
Committed by
GitHub
Apr 24, 2020
Browse files
[R-package] Added tests on LGBM_GetLastError_R (#3005)
parent
22d6d1fd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
R-package/R/utils.R
R-package/R/utils.R
+2
-0
R-package/tests/testthat/test_utils.R
R-package/tests/testthat/test_utils.R
+20
-0
No files found.
R-package/R/utils.R
View file @
5304885c
...
...
@@ -19,6 +19,8 @@ lgb.encode.char <- function(arr, len) {
}
# [description] Raise an error. Before raising that error, check for any error message
# stored in a buffer on the C++ side.
lgb.last_error
<-
function
()
{
# Perform text error buffering
buf_len
<-
200L
...
...
R-package/tests/testthat/test_utils.R
View file @
5304885c
...
...
@@ -48,3 +48,23 @@ test_that("lgb.params2str() works as expected for a key in params with multiple
,
"objective=magic metric=a,ab,abc,abcdefg nrounds=10 learning_rate=0.0000001"
)
})
context
(
"lgb.last_error"
)
test_that
(
"lgb.last_error() throws an error if there are no errors"
,
{
expect_error
({
lgb.last_error
()
},
regexp
=
"Everything is fine"
)
})
test_that
(
"lgb.last_error() correctly returns errors from the C++ side"
,
{
data
(
agaricus.train
,
package
=
"lightgbm"
)
train
<-
agaricus.train
dvalid1
<-
lgb.Dataset
(
data
=
train
$
data
,
label
=
as.matrix
(
rnorm
(
5L
))
)
expect_error
({
dvalid1
$
construct
()
},
regexp
=
"[LightGBM] [Fatal] Length of label is not same with #data"
,
fixed
=
TRUE
)
})
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