Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
9
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Artem Klevtsov
RcppUUID
Commits
fb3d4194
Verified
Commit
fb3d4194
authored
Feb 12, 2020
by
Artem Klevtsov
😹
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests
parent
a965d305
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
3 deletions
+5
-3
inst/tinytest/test-generate.R
inst/tinytest/test-generate.R
+2
-1
inst/tinytest/test-validate.R
inst/tinytest/test-validate.R
+2
-1
src/uuid.cpp
src/uuid.cpp
+1
-1
No files found.
inst/tinytest/test-generate.R
View file @
fb3d4194
...
...
@@ -2,7 +2,8 @@
ptrn
<-
"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}"
expect_error
(
uuid_generate
(
NULL
))
expect_error
(
uuid_generate
(
NA
))
# expect_error(uuid_generate(NA_integer_))
expect_error
(
uuid_generate
(
c
(
0
,
0
)))
expect_equal
(
uuid_generate
(
0
),
character
(
0
))
expect_true
(
is.character
(
uuid_generate
(
1
)))
expect_true
(
grepl
(
ptrn
,
uuid_generate
(
1
)))
...
...
inst/tinytest/test-validate.R
View file @
fb3d4194
expect_error
(
uuid_validate
(
NULL
))
expect_equal
(
uuid_validate
(
NA
),
NA
)
expect_
equal
(
uuid_validate
(
""
),
NA
)
expect_
false
(
uuid_validate
(
""
),
NA
)
expect_false
(
uuid_validate
(
"0"
))
expect_false
(
all
(
uuid_validate
(
c
(
"0"
,
"0"
))))
expect_equal
(
length
(
uuid_generate
(
7
)),
7
)
expect_true
(
uuid_validate
(
uuid_generate
(
1
)))
expect_true
(
all
(
uuid_validate
(
uuid_generate
(
100
))))
src/uuid.cpp
View file @
fb3d4194
...
...
@@ -60,7 +60,7 @@ Rcpp::LogicalVector uuid_validate(Rcpp::StringVector x) {
size_t
n
=
x
.
size
();
Rcpp
::
LogicalVector
res
=
Rcpp
::
no_init
(
n
);
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
if
(
x
[
i
].
empty
()
||
Rcpp
::
StringVector
::
is_na
(
x
[
i
]))
{
if
(
Rcpp
::
StringVector
::
is_na
(
x
[
i
]))
{
res
[
i
]
=
NA_LOGICAL
;
}
else
{
res
[
i
]
=
uuids
::
uuid
::
is_valid_uuid
(
std
::
string
(
x
[
i
]));
...
...
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