Skip to content

Commit

Permalink
Add min/max handling tests
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Jaegervall <[email protected]>
  • Loading branch information
erikbosch committed May 17, 2024
1 parent 109b3ed commit d0b456d
Show file tree
Hide file tree
Showing 8 changed files with 575 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/vspec/test_min_max/expected.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"Signal","Type","DataType","Deprecated","Unit","Min","Max","Desc","Comment","Allowed","Default"
"A","branch","","","","","","Branch A.","","",""
"A.IntNoMinMax","sensor","int8","","","","","No Min Max.","","",""
"A.IntOnlyMax","sensor","int8","","","","32","Only Max.","","",""
"A.IntOnlyMin","sensor","int8","","","3","","Only Min.","","",""
"A.IntMinMax","sensor","int8","","","3","6","Min & Max.","","",""
"A.IntMaxZero","sensor","int8","","","","0","Max Zero.","","",""
"A.IntMinZero","sensor","int8","","","0","","Min Zero.","","",""
"A.FloatNoMinMax","sensor","float","","","","","No Min Max.","","",""
"A.FloatOnlyMax","sensor","float","","","","32.3","Only Max.","","",""
"A.FloatOnlyMin","sensor","float","","","-2.5","","Only Min.","","",""
"A.FloatMinMax","sensor","float","","","-165.56323","236723.4","Min & Max.","","",""
"A.FloatMaxZero","sensor","float","","","","0.0","Max Zero.","","",""
"A.FloatMinZero","sensor","float","","","0.0","","Min Zero.","","",""
"A.FloatMaxZeroInt","sensor","float","","","","0","Max Zero.","","",""
"A.FloatMinZeroInt","sensor","float","","","0","","Min Zero.","","",""
87 changes: 87 additions & 0 deletions tests/vspec/test_min_max/expected.ddsidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
module A
{
struct IntNoMinMax
{
octet value;
//const string type ="sensor";
//const string description="No Min Max.";
};
struct IntOnlyMax
{
octet value;
//const string type ="sensor";
//const string description="Only Max.";
};
struct IntOnlyMin
{
octet value;
//const string type ="sensor";
//const string description="Only Min.";
};
struct IntMinMax
{
octet value;
//const string type ="sensor";
//const string description="Min & Max.";
};
struct IntMaxZero
{
octet value;
//const string type ="sensor";
//const string description="Max Zero.";
};
struct IntMinZero
{
octet value;
//const string type ="sensor";
//const string description="Min Zero.";
};
struct FloatNoMinMax
{
float value;
//const string type ="sensor";
//const string description="No Min Max.";
};
struct FloatOnlyMax
{
float value;
//const string type ="sensor";
//const string description="Only Max.";
};
struct FloatOnlyMin
{
float value;
//const string type ="sensor";
//const string description="Only Min.";
};
struct FloatMinMax
{
float value;
//const string type ="sensor";
//const string description="Min & Max.";
};
struct FloatMaxZero
{
float value;
//const string type ="sensor";
//const string description="Max Zero.";
};
struct FloatMinZero
{
float value;
//const string type ="sensor";
//const string description="Min Zero.";
};
struct FloatMaxZeroInt
{
float value;
//const string type ="sensor";
//const string description="Max Zero.";
};
struct FloatMinZeroInt
{
float value;
//const string type ="sensor";
//const string description="Min Zero.";
};
};
100 changes: 100 additions & 0 deletions tests/vspec/test_min_max/expected.franca
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@

// Copyright (C) 2022, COVESA
//
// This program is licensed under the terms and conditions of the
// Mozilla Public License, version 2.0. The full text of the
// Mozilla Public License is at https://www.mozilla.org/MPL/2.0/

const UTF8String VSS_VERSION = "None"

struct SignalSpec {
UInt32 id
String name
String type
String description
String datatype
String unit
Double min
Double max
}

const SignalSpec[] signal_spec = [
{ name: "A.IntNoMinMax",
type: "sensor",
description: "No Min Max.",
datatype: "int8"
},
{ name: "A.IntOnlyMax",
type: "sensor",
description: "Only Max.",
datatype: "int8",
max: 32
},
{ name: "A.IntOnlyMin",
type: "sensor",
description: "Only Min.",
datatype: "int8",
min: 3
},
{ name: "A.IntMinMax",
type: "sensor",
description: "Min & Max.",
datatype: "int8",
min: 3,
max: 6
},
{ name: "A.IntMaxZero",
type: "sensor",
description: "Max Zero.",
datatype: "int8"
},
{ name: "A.IntMinZero",
type: "sensor",
description: "Min Zero.",
datatype: "int8"
},
{ name: "A.FloatNoMinMax",
type: "sensor",
description: "No Min Max.",
datatype: "float"
},
{ name: "A.FloatOnlyMax",
type: "sensor",
description: "Only Max.",
datatype: "float",
max: 32.3
},
{ name: "A.FloatOnlyMin",
type: "sensor",
description: "Only Min.",
datatype: "float",
min: -2.5
},
{ name: "A.FloatMinMax",
type: "sensor",
description: "Min & Max.",
datatype: "float",
min: -165.56323,
max: 236723.4
},
{ name: "A.FloatMaxZero",
type: "sensor",
description: "Max Zero.",
datatype: "float"
},
{ name: "A.FloatMinZero",
type: "sensor",
description: "Min Zero.",
datatype: "float"
},
{ name: "A.FloatMaxZeroInt",
type: "sensor",
description: "Max Zero.",
datatype: "float"
},
{ name: "A.FloatMinZeroInt",
type: "sensor",
description: "Min Zero.",
datatype: "float"
}
]
182 changes: 182 additions & 0 deletions tests/vspec/test_min_max/expected.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
type Query {
vehicle(
"""VIN of the vehicle that you want to request data for."""
id: String!

"""
Filter data to only provide information that was sent from the vehicle after that timestamp.
"""
after: String
): A
}

"""Branch A."""
type A {
"""No Min Max."""
intNoMinMax: A_IntNoMinMax

"""Only Max."""
intOnlyMax: A_IntOnlyMax

"""Only Min."""
intOnlyMin: A_IntOnlyMin

"""Min & Max."""
intMinMax: A_IntMinMax

"""Max Zero."""
intMaxZero: A_IntMaxZero

"""Min Zero."""
intMinZero: A_IntMinZero

"""No Min Max."""
floatNoMinMax: A_FloatNoMinMax

"""Only Max."""
floatOnlyMax: A_FloatOnlyMax

"""Only Min."""
floatOnlyMin: A_FloatOnlyMin

"""Min & Max."""
floatMinMax: A_FloatMinMax

"""Max Zero."""
floatMaxZero: A_FloatMaxZero

"""Min Zero."""
floatMinZero: A_FloatMinZero

"""Max Zero."""
floatMaxZeroInt: A_FloatMaxZeroInt

"""Min Zero."""
floatMinZeroInt: A_FloatMinZeroInt
}

"""No Min Max."""
type A_IntNoMinMax {
"""Value: No Min Max."""
value: Int

"""Timestamp: No Min Max."""
timestamp: String
}

"""Only Max."""
type A_IntOnlyMax {
"""Value: Only Max."""
value: Int

"""Timestamp: Only Max."""
timestamp: String
}

"""Only Min."""
type A_IntOnlyMin {
"""Value: Only Min."""
value: Int

"""Timestamp: Only Min."""
timestamp: String
}

"""Min & Max."""
type A_IntMinMax {
"""Value: Min & Max."""
value: Int

"""Timestamp: Min & Max."""
timestamp: String
}

"""Max Zero."""
type A_IntMaxZero {
"""Value: Max Zero."""
value: Int

"""Timestamp: Max Zero."""
timestamp: String
}

"""Min Zero."""
type A_IntMinZero {
"""Value: Min Zero."""
value: Int

"""Timestamp: Min Zero."""
timestamp: String
}

"""No Min Max."""
type A_FloatNoMinMax {
"""Value: No Min Max."""
value: Float

"""Timestamp: No Min Max."""
timestamp: String
}

"""Only Max."""
type A_FloatOnlyMax {
"""Value: Only Max."""
value: Float

"""Timestamp: Only Max."""
timestamp: String
}

"""Only Min."""
type A_FloatOnlyMin {
"""Value: Only Min."""
value: Float

"""Timestamp: Only Min."""
timestamp: String
}

"""Min & Max."""
type A_FloatMinMax {
"""Value: Min & Max."""
value: Float

"""Timestamp: Min & Max."""
timestamp: String
}

"""Max Zero."""
type A_FloatMaxZero {
"""Value: Max Zero."""
value: Float

"""Timestamp: Max Zero."""
timestamp: String
}

"""Min Zero."""
type A_FloatMinZero {
"""Value: Min Zero."""
value: Float

"""Timestamp: Min Zero."""
timestamp: String
}

"""Max Zero."""
type A_FloatMaxZeroInt {
"""Value: Max Zero."""
value: Float

"""Timestamp: Max Zero."""
timestamp: String
}

"""Min Zero."""
type A_FloatMinZeroInt {
"""Value: Min Zero."""
value: Float

"""Timestamp: Min Zero."""
timestamp: String
}
1 change: 1 addition & 0 deletions tests/vspec/test_min_max/expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"A": {"children": {"FloatMaxZero": {"datatype": "float", "description": "Max Zero.", "max": 0.0, "type": "sensor"}, "FloatMaxZeroInt": {"datatype": "float", "description": "Max Zero.", "max": 0, "type": "sensor"}, "FloatMinMax": {"datatype": "float", "description": "Min & Max.", "max": 236723.4, "min": -165.56323, "type": "sensor"}, "FloatMinZero": {"datatype": "float", "description": "Min Zero.", "min": 0.0, "type": "sensor"}, "FloatMinZeroInt": {"datatype": "float", "description": "Min Zero.", "min": 0, "type": "sensor"}, "FloatNoMinMax": {"datatype": "float", "description": "No Min Max.", "type": "sensor"}, "FloatOnlyMax": {"datatype": "float", "description": "Only Max.", "max": 32.3, "type": "sensor"}, "FloatOnlyMin": {"datatype": "float", "description": "Only Min.", "min": -2.5, "type": "sensor"}, "IntMaxZero": {"datatype": "int8", "description": "Max Zero.", "max": 0, "type": "sensor"}, "IntMinMax": {"datatype": "int8", "description": "Min & Max.", "max": 6, "min": 3, "type": "sensor"}, "IntMinZero": {"datatype": "int8", "description": "Min Zero.", "min": 0, "type": "sensor"}, "IntNoMinMax": {"datatype": "int8", "description": "No Min Max.", "type": "sensor"}, "IntOnlyMax": {"datatype": "int8", "description": "Only Max.", "max": 32, "type": "sensor"}, "IntOnlyMin": {"datatype": "int8", "description": "Only Min.", "min": 3, "type": "sensor"}}, "description": "Branch A.", "type": "branch"}}
1 change: 1 addition & 0 deletions tests/vspec/test_min_max/expected.jsonschema
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"$schema": "https://json-schema.org/draft/2020-12/schema", "title": "A", "type": "object", "description": "Branch A.", "properties": {"IntNoMinMax": {"description": "No Min Max.", "type": "integer"}, "IntOnlyMax": {"description": "Only Max.", "type": "integer", "maximum": 32}, "IntOnlyMin": {"description": "Only Min.", "type": "integer", "minimum": 3}, "IntMinMax": {"description": "Min & Max.", "type": "integer", "minimum": 3, "maximum": 6}, "IntMaxZero": {"description": "Max Zero.", "type": "integer", "maximum": 0}, "IntMinZero": {"description": "Min Zero.", "type": "integer", "minimum": 0}, "FloatNoMinMax": {"description": "No Min Max.", "type": "number"}, "FloatOnlyMax": {"description": "Only Max.", "type": "number", "maximum": 32.3}, "FloatOnlyMin": {"description": "Only Min.", "type": "number", "minimum": -2.5}, "FloatMinMax": {"description": "Min & Max.", "type": "number", "minimum": -165.56323, "maximum": 236723.4}, "FloatMaxZero": {"description": "Max Zero.", "type": "number", "maximum": 0.0}, "FloatMinZero": {"description": "Min Zero.", "type": "number", "minimum": 0.0}, "FloatMaxZeroInt": {"description": "Max Zero.", "type": "number", "maximum": 0}, "FloatMinZeroInt": {"description": "Min Zero.", "type": "number", "minimum": 0}}}
Loading

0 comments on commit d0b456d

Please sign in to comment.