Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
lab3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Havard.Kolve
lab3
Commits
cf59980f
Commit
cf59980f
authored
2 years ago
by
Havard Kolve
Browse files
Options
Downloads
Patches
Plain Diff
oblig
parent
3317175a
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
src/test/java/no/uib/inf101/terminal/TestSimpleShellStarter.java
+40
-40
40 additions, 40 deletions
...t/java/no/uib/inf101/terminal/TestSimpleShellStarter.java
with
40 additions
and
40 deletions
src/test/java/no/uib/inf101/terminal/TestSimpleShellStarter.java
+
40
−
40
View file @
cf59980f
...
...
@@ -23,71 +23,71 @@ public class TestSimpleShellStarter {
@Test
public
void
testDoNothing
()
{
assertEquals
(
"$ "
,
shell
.
whatTheScreenLooksLike
());
assertEquals
(
"$ "
,
shell
.
getScreenContent
());
}
@Test
public
void
testWriteFoo
()
{
shell
.
aKeyIs
Pressed
(
'f'
);
shell
.
aKeyIs
Pressed
(
'o'
);
shell
.
aKeyIs
Pressed
(
'o'
);
shell
.
key
Pressed
(
'f'
);
shell
.
key
Pressed
(
'o'
);
shell
.
key
Pressed
(
'o'
);
assertEquals
(
"$ foo"
,
shell
.
whatTheScreenLooksLike
());
assertEquals
(
"$ foo"
,
shell
.
getScreenContent
());
}
@Test
public
void
testIllegalCommand
()
{
shell
.
aKeyIs
Pressed
(
'f'
);
shell
.
aKeyIs
Pressed
(
'o'
);
shell
.
aKeyIs
Pressed
(
'o'
);
shell
.
aKeyIs
Pressed
(
'\n'
);
shell
.
key
Pressed
(
'f'
);
shell
.
key
Pressed
(
'o'
);
shell
.
key
Pressed
(
'o'
);
shell
.
key
Pressed
(
'\n'
);
assertEquals
(
"$ foo\nCommand not found: \"foo\"\n$ "
,
shell
.
whatTheScreenLooksLike
());
assertEquals
(
"$ foo\nCommand not found: \"foo\"\n$ "
,
shell
.
getScreenContent
());
}
@Test
public
void
testPwd
()
throws
IOException
{
shell
.
aKeyIs
Pressed
(
'p'
);
shell
.
aKeyIs
Pressed
(
'w'
);
shell
.
aKeyIs
Pressed
(
'd'
);
shell
.
aKeyIs
Pressed
(
'\n'
);
shell
.
key
Pressed
(
'p'
);
shell
.
key
Pressed
(
'w'
);
shell
.
key
Pressed
(
'd'
);
shell
.
key
Pressed
(
'\n'
);
String
expected
=
"$ pwd"
+
"\n"
+
this
.
dir
.
getCanonicalPath
()
+
"\n$ "
;
assertEquals
(
expected
,
shell
.
whatTheScreenLooksLike
());
assertEquals
(
expected
,
shell
.
getScreenContent
());
}
@Test
public
void
testLs
()
throws
IOException
{
shell
.
aKeyIs
Pressed
(
'l'
);
shell
.
aKeyIs
Pressed
(
's'
);
shell
.
aKeyIs
Pressed
(
'\n'
);
shell
.
key
Pressed
(
'l'
);
shell
.
key
Pressed
(
's'
);
shell
.
key
Pressed
(
'\n'
);
String
expected
=
"$ ls\n"
+
SUBDIR
+
" \n$ "
;
assertEquals
(
expected
,
shell
.
whatTheScreenLooksLike
());
assertEquals
(
expected
,
shell
.
getScreenContent
());
}
@Test
public
void
testCd
()
throws
IOException
{
shell
.
aKeyIs
Pressed
(
'p'
);
shell
.
aKeyIs
Pressed
(
'w'
);
shell
.
aKeyIs
Pressed
(
'd'
);
shell
.
aKeyIs
Pressed
(
'\n'
);
shell
.
aKeyIs
Pressed
(
'c'
);
shell
.
aKeyIs
Pressed
(
'd'
);
shell
.
aKeyIs
Pressed
(
' '
);
shell
.
aKeyIs
Pressed
(
's'
);
shell
.
aKeyIs
Pressed
(
'u'
);
shell
.
aKeyIs
Pressed
(
'b'
);
shell
.
aKeyIs
Pressed
(
'd'
);
shell
.
aKeyIs
Pressed
(
'i'
);
shell
.
aKeyIs
Pressed
(
'r'
);
shell
.
aKeyIs
Pressed
(
'\n'
);
shell
.
aKeyIs
Pressed
(
'p'
);
shell
.
aKeyIs
Pressed
(
'w'
);
shell
.
aKeyIs
Pressed
(
'd'
);
shell
.
aKeyIs
Pressed
(
'\n'
);
shell
.
key
Pressed
(
'p'
);
shell
.
key
Pressed
(
'w'
);
shell
.
key
Pressed
(
'd'
);
shell
.
key
Pressed
(
'\n'
);
shell
.
key
Pressed
(
'c'
);
shell
.
key
Pressed
(
'd'
);
shell
.
key
Pressed
(
' '
);
shell
.
key
Pressed
(
's'
);
shell
.
key
Pressed
(
'u'
);
shell
.
key
Pressed
(
'b'
);
shell
.
key
Pressed
(
'd'
);
shell
.
key
Pressed
(
'i'
);
shell
.
key
Pressed
(
'r'
);
shell
.
key
Pressed
(
'\n'
);
shell
.
key
Pressed
(
'p'
);
shell
.
key
Pressed
(
'w'
);
shell
.
key
Pressed
(
'd'
);
shell
.
key
Pressed
(
'\n'
);
String
expected
=
"$ pwd\n"
...
...
@@ -97,7 +97,7 @@ public class TestSimpleShellStarter {
+
this
.
subdir
.
getCanonicalPath
()
+
"\n"
+
"$ "
;
assertEquals
(
expected
,
shell
.
whatTheScreenLooksLike
());
assertEquals
(
expected
,
shell
.
getScreenContent
());
}
...
...
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