Skip to content

Commit

Permalink
fixed test
Browse files Browse the repository at this point in the history
  • Loading branch information
arcuri82 committed Jan 1, 2025
1 parent 410409a commit 4284850
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class QueryParam(
init {
//https://swagger.io/docs/specification/serialization/
/*
sending x=[1,2,3] intead of x=1,2,3 is wrong, and can lead to crashes in
sending x=[1,2,3] instead of x=1,2,3 is wrong, and can lead to crashes in
server if desearilazation is not properly handled.
TODO: But sending such malformatted string should be handled as part of Robustness Testing
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ import org.evomaster.core.search.service.mutator.genemutation.SubsetGeneMutation
* time-minute = 2DIGIT ; 00-59
* time-numoffset = ("+" / "-") time-hour ":" time-minute
* time-offset = "Z" / time-numoffset
*
* Note: RFC3339 does NOT put constraints on hour, but Java does, ie, range -18,+18.
* Apparently this is based on ISO8601, which RFC3339 "profiles"... but
* that document costs money to read... also, it seems currently only -14,+12 is used
* in practice in the world
*/
class TimeNumOffsetGene(
name: String,
val sign: EnumGene<String> = EnumGene("sign", listOf("-","+"), treatAsNotString = true),
val hour: IntegerGene = IntegerGene("hour", min = 0, max = 23),
val hour: IntegerGene = IntegerGene("hour", min = 0, max = 18),
val minute: IntegerGene = IntegerGene("minute", min = 0, max = 59)
) : CompositeFixedGene(name, listOf(sign, hour, minute)) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ class TimeRest {
return ResponseEntity.badRequest().body(e.message)
}

//checking different offsets
if(x.contains("Z") ){
return ResponseEntity.ok("A")
}
if(x.contains("-") ){
// there are always 2 - before the T
if(x.chars().filter{it == '-'.code}.count() == 3L ){
return ResponseEntity.ok("B")
}
if(x.contains("+") ){
return ResponseEntity.ok("C")
}

//this shouldn't be reachable
return ResponseEntity.ok("D")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TimeEMTest : SpringTestBase(){

runTestHandlingFlakyAndCompilation(
"TimeEM",
100
1000
) { args: MutableList<String> ->

val solution = initAndRun(args)
Expand All @@ -32,7 +32,7 @@ class TimeEMTest : SpringTestBase(){
assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/api/time", "A")
assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/api/time", "B")
assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/api/time", "C")
assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/api/time", "D")
assertNone(solution, HttpVerb.GET, 200, "/api/time", "D")
}
}
}

0 comments on commit 4284850

Please sign in to comment.