Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Proost
Manage
Activity
Members
Labels
Plan
Issues
33
Issue boards
Milestones
Code
Merge requests
18
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Model registry
Operate
Terraform modules
Analyze
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
loutr
Proost
Compare revisions
main to 71-panic-when-entering-a
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
loutr/proost
Select target project
No results found
71-panic-when-entering-a
Select Git revision
Swap
Target
loutr/proost
Select target project
loutr/proost
jeanas/proost
2 results
main
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
fix(proost): add missing boundary check
· b738691e
aalbert
authored
2 years ago
Verified
b738691e
feat(proost): add test for is_command behavior with 1 letter
· c03cb62b
aalbert
authored
2 years ago
Verified
c03cb62b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
proost/src/main.rs
+14
-1
14 additions, 1 deletion
proost/src/main.rs
with
14 additions
and
1 deletion
proost/src/main.rs
View file @
c03cb62b
...
...
@@ -78,12 +78,25 @@ fn main() -> Result<'static, ()> {
}
fn
is_command
(
input
:
&
str
)
->
bool
{
input
.chars
()
.position
(|
c
|
!
c
.is_whitespace
())
.map
(|
pos
|
input
[
pos
..
pos
+
2
]
!=
*
"//"
)
.unwrap_or_else
(||
false
)
input
.chars
()
.position
(|
c
|
!
c
.is_whitespace
())
.map
(|
pos
|
input
.len
()
<
2
||
input
[
pos
..
pos
+
2
]
!=
*
"//"
)
.unwrap_or_else
(||
false
)
}
#[cfg(test)]
mod
tests
{
#[test]
fn
is_command_no_crash
()
{
assert!
(
!
super
::
is_command
(
""
));
assert!
(
super
::
is_command
(
"a"
));
assert!
(
super
::
is_command
(
"aa"
));
assert!
(
super
::
is_command
(
"aaa"
));
assert!
(
super
::
is_command
(
"aaaa"
));
}
#[test]
fn
is_command_false
()
{
assert!
(
!
super
::
is_command
(
" "
));
...
...
This diff is collapsed.
Click to expand it.