Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tester
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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
insert epic projlab name here
tester
Commits
f3825ad5
Verified
Commit
f3825ad5
authored
4 years ago
by
Tóth Miklós Tibor
Browse files
Options
Downloads
Patches
Plain Diff
file testing
parent
a631cabf
No related branches found
No related tags found
No related merge requests found
Pipeline
#7936
passed
4 years ago
Stage: build
Changes
1
Pipelines
111
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/tester/Main.java
+21
-8
21 additions, 8 deletions
src/main/java/tester/Main.java
with
21 additions
and
8 deletions
src/main/java/tester/Main.java
+
21
−
8
View file @
f3825ad5
...
@@ -6,8 +6,8 @@ import java.io.*;
...
@@ -6,8 +6,8 @@ import java.io.*;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.util.Base64
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.stream.Stream
;
public
class
Main
{
public
class
Main
{
...
@@ -23,6 +23,10 @@ public class Main {
...
@@ -23,6 +23,10 @@ public class Main {
return
sb
.
toString
();
return
sb
.
toString
();
}
}
private
static
byte
[]
decodeB64
(
String
input
)
{
return
Base64
.
getDecoder
().
decode
(
input
);
}
private
static
boolean
runTest
(
String
jarfile
,
String
testName
)
throws
FileNotFoundException
{
private
static
boolean
runTest
(
String
jarfile
,
String
testName
)
throws
FileNotFoundException
{
System
.
out
.
printf
(
"Running test \"%s\"\n"
,
testName
);
System
.
out
.
printf
(
"Running test \"%s\"\n"
,
testName
);
...
@@ -97,8 +101,8 @@ public class Main {
...
@@ -97,8 +101,8 @@ public class Main {
System
.
out
.
printf
(
"File: %s\n"
,
f
);
System
.
out
.
printf
(
"File: %s\n"
,
f
);
System
.
out
.
println
();
System
.
out
.
println
();
try
{
try
{
String
got
=
f
ile
ToString
(
f
);
byte
[]
got
=
F
ile
s
.
readAllBytes
(
Paths
.
get
(
f
)
)
;
boolean
erro
=
compare
String
s
(
got
,
e
);
boolean
erro
=
compare
File
s
(
got
,
decodeB64
(
e
)
);
if
(
erro
)
{
if
(
erro
)
{
error
.
set
(
true
);
error
.
set
(
true
);
}
else
{
}
else
{
...
@@ -211,10 +215,19 @@ public class Main {
...
@@ -211,10 +215,19 @@ public class Main {
return
error
;
return
error
;
}
}
private
static
String
fileToString
(
String
path
)
throws
IOException
{
private
static
boolean
compareFiles
(
byte
[]
got
,
byte
[]
expect
)
{
StringBuilder
build
=
new
StringBuilder
();
if
(
got
.
length
!=
expect
.
length
)
{
Stream
<
String
>
stream
=
Files
.
lines
(
Paths
.
get
(
path
),
StandardCharsets
.
UTF_8
);
System
.
out
.
println
(
"❌ A fájlméretek különböznek"
);
stream
.
forEach
(
s
->
build
.
append
(
s
).
append
(
"\n"
));
return
false
;
return
build
.
toString
();
}
var
err
=
false
;
for
(
int
i
=
0
;
i
<
expect
.
length
;
i
++)
{
if
(
got
[
i
]
!=
expect
[
i
])
{
System
.
out
.
printf
(
"❌ A %d. byte (karakter) nem passzol\n"
,
i
);
err
=
true
;
}
}
return
err
;
}
}
}
}
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