1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tools: make v test-cleancode test everything by default (#10050)

This commit is contained in:
Delyan Angelov
2021-05-08 13:32:29 +03:00
committed by GitHub
parent cba2cb6b9c
commit 8a380f4699
132 changed files with 3230 additions and 3440 deletions

View File

@ -6,12 +6,11 @@ struct TestPair {
}
const (
pairs = [
pairs = [
// RFC 3548 examples
TestPair{'\x14\xfb\x9c\x03\xd9\x7e', 'FPucA9l+'},
TestPair{'\x14\xfb\x9c\x03\xd9', 'FPucA9k='},
TestPair{'\x14\xfb\x9c\x03', 'FPucAw=='},
// RFC 4648 examples
TestPair{'', ''},
TestPair{'f', 'Zg=='},
@ -20,7 +19,6 @@ const (
TestPair{'foob', 'Zm9vYg=='},
TestPair{'fooba', 'Zm9vYmE='},
TestPair{'foobar', 'Zm9vYmFy'},
// Wikipedia examples
TestPair{'sure.', 'c3VyZS4='},
TestPair{'sure', 'c3VyZQ=='},
@ -32,11 +30,7 @@ const (
TestPair{'sure.', 'c3VyZS4='},
]
man_pair = TestPair{
'Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.',
'TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4='
}
man_pair = TestPair{'Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.', 'TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4='}
)
fn test_decode() {
@ -50,7 +44,7 @@ fn test_decode() {
for i, p in pairs {
got := base64.decode(p.encoded)
if got != p.decoded.bytes() {
eprintln('pairs[${i}]: expected = ${p.decoded}, got = ${got}')
eprintln('pairs[$i]: expected = $p.decoded, got = $got')
assert false
}
}
@ -67,7 +61,7 @@ fn test_decode_str() {
for i, p in pairs {
got := base64.decode_str(p.encoded)
if got != p.decoded {
eprintln('pairs[${i}]: expected = ${p.decoded}, got = ${got}')
eprintln('pairs[$i]: expected = $p.decoded, got = $got')
assert false
}
}
@ -79,7 +73,7 @@ fn test_encode() {
for i, p in pairs {
got := base64.encode(p.decoded.bytes())
if got != p.encoded {
eprintln('pairs[${i}]: expected = ${p.encoded}, got = ${got}')
eprintln('pairs[$i]: expected = $p.encoded, got = $got')
assert false
}
}
@ -91,7 +85,7 @@ fn test_encode_str() {
for i, p in pairs {
got := base64.encode_str(p.decoded)
if got != p.encoded {
eprintln('pairs[${i}]: expected = ${p.encoded}, got = ${got}')
eprintln('pairs[$i]: expected = $p.encoded, got = $got')
assert false
}
}
@ -108,31 +102,31 @@ fn test_url_encode_str() {
}
fn test_url_decode() {
test := base64.url_decode("SGVsbG8gQmFzZTY0VXJsIGVuY29kaW5nIQ")
test := base64.url_decode('SGVsbG8gQmFzZTY0VXJsIGVuY29kaW5nIQ')
assert test == 'Hello Base64Url encoding!'.bytes()
}
fn test_url_decode_str() {
test := base64.url_decode_str("SGVsbG8gQmFzZTY0VXJsIGVuY29kaW5nIQ")
test := base64.url_decode_str('SGVsbG8gQmFzZTY0VXJsIGVuY29kaW5nIQ')
assert test == 'Hello Base64Url encoding!'
}
fn test_encode_null_byte() {
assert base64.encode([byte(`A`) 0 `C`]) == 'QQBD'
assert base64.encode([byte(`A`), 0, `C`]) == 'QQBD'
}
fn test_encode_null_byte_str() {
// While this works, bytestr() does a memcpy
s := [byte(`A`) 0 `C`].bytestr()
s := [byte(`A`), 0, `C`].bytestr()
assert base64.encode_str(s) == 'QQBD'
}
fn test_decode_null_byte() {
assert base64.decode('QQBD') == [byte(`A`) 0 `C`]
assert base64.decode('QQBD') == [byte(`A`), 0, `C`]
}
fn test_decode_null_byte_str() {
// While this works, bytestr() does a memcpy
s := [byte(`A`) 0 `C`].bytestr()
s := [byte(`A`), 0, `C`].bytestr()
assert base64.decode_str('QQBD') == s
}