mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: change optional to result in most of the libraries (#16123)
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import encoding.base58
|
||||
import encoding.hex
|
||||
|
||||
fn test_encode() ? {
|
||||
fn test_encode() {
|
||||
for input, expected in {
|
||||
'': ''
|
||||
'6263': '2PMCRQ'
|
||||
@ -14,20 +14,20 @@ fn test_encode() ? {
|
||||
}
|
||||
}
|
||||
|
||||
fn test_encode_int() ? {
|
||||
fn test_encode_int() {
|
||||
for input, expected in {
|
||||
0x6263: '8VG'
|
||||
0x61: '2g'
|
||||
0x626262: 'a3gV'
|
||||
0x636363: 'aPEr'
|
||||
} {
|
||||
output := base58.encode_int(input)?
|
||||
output := base58.encode_int(input)!
|
||||
println('> input: 0x${input:x} | => output: `$output`')
|
||||
assert output == expected
|
||||
}
|
||||
}
|
||||
|
||||
fn test_decode() ? {
|
||||
fn test_decode() {
|
||||
for output, expected in {
|
||||
'USm3fpXnKG5EUBx2ndxBDMPVciP5hGey2Jh4NDv6gmeo1LkMeiKrLJUUBk6Z': 'The quick brown fox jumps over the lazy dog.'
|
||||
'11StV1DL6CwTryKyV': '\x00\x00hello world'
|
||||
@ -35,7 +35,7 @@ fn test_decode() ? {
|
||||
'14cxpo3MBCYYWCgF74SWTdcmxipnGUsPw3': hex.decode('0027b5891b01da2db74cde1689a97a2acbe23d5fb1c0205bf6')?.bytestr()
|
||||
'3vQB7B6MrGQZaxCuFg4oh': hex.decode('68656c6c6f20776f726c64bc62d4b8')?.bytestr()
|
||||
} {
|
||||
input := base58.decode(output)?
|
||||
input := base58.decode(output)!
|
||||
println('> output: `$output` | decoded input: `$input` | bytes: $input.bytes().hex()')
|
||||
assert input.bytes().hex() == expected.bytes().hex()
|
||||
}
|
||||
|
Reference in New Issue
Block a user