the base
This commit is contained in:
28
lib/data/paramsparser/params_getresource_test.v
Normal file
28
lib/data/paramsparser/params_getresource_test.v
Normal file
@@ -0,0 +1,28 @@
|
||||
module paramsparser
|
||||
|
||||
fn test_resource_capacity_in_bytes() {
|
||||
text := 'memory: 10KB\ndisk: 10MB\nstorage: 10GB\nssd: 10'
|
||||
params := parse(text)!
|
||||
assert params.get_storagecapacity_in_bytes('memory')! == 10 * 1024
|
||||
assert params.get_storagecapacity_in_bytes('disk')! == 10 * 1024 * 1024
|
||||
assert params.get_storagecapacity_in_bytes('storage')! == u64(10) * 1024 * 1024 * 1024
|
||||
assert params.get_storagecapacity_in_bytes('ssd')! == 10
|
||||
}
|
||||
|
||||
fn test_resource_capacity_in_bytes_default() {
|
||||
text := 'memory: 10KB\ndisk: 10MB\nstorage: 10GB'
|
||||
params := parse(text)!
|
||||
assert params.get_storagecapacity_in_bytes_default('memory', 10)! == 10 * 1024
|
||||
assert params.get_storagecapacity_in_bytes_default('disk', 10)! == 10 * 1024 * 1024
|
||||
assert params.get_storagecapacity_in_bytes_default('storage', 10)! == u64(10) * 1024 * 1024 * 1024
|
||||
assert params.get_storagecapacity_in_bytes_default('nonexistent', 10)! == 10
|
||||
}
|
||||
|
||||
fn test_resource_capacity_in_gigabytes() {
|
||||
text := 'memory: 10KB\ndisk: 10MB\nstorage: 10GB\nssd: 10'
|
||||
p := parse(text)!
|
||||
assert p.get_storagecapacity_in_gigabytes('memory')! == 1
|
||||
assert p.get_storagecapacity_in_gigabytes('disk')! == 1
|
||||
assert p.get_storagecapacity_in_gigabytes('storage')! == 10
|
||||
assert p.get_storagecapacity_in_gigabytes('ssd')! == 10
|
||||
}
|
||||
Reference in New Issue
Block a user