mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fix new enums in tests
This commit is contained in:
parent
aa39451c8b
commit
2bd2501dc0
@ -5,22 +5,18 @@ enum Color {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn test_enum() {
|
fn test_enum() {
|
||||||
assert Color.red == Color.red
|
|
||||||
assert Color.blue == Color.blue
|
|
||||||
assert Color.green == Color.green
|
|
||||||
|
|
||||||
assert Color.red == .red
|
assert Color.red == .red
|
||||||
assert Color.blue == .blue
|
assert Color.blue == .blue
|
||||||
assert Color.green == .green
|
assert Color.green == .green
|
||||||
|
|
||||||
assert Color.red != Color.blue
|
assert Color.red != .blue
|
||||||
assert Color.red != Color.green
|
assert Color.red != .green
|
||||||
assert Color.blue != Color.green
|
assert Color.blue != .green
|
||||||
|
|
||||||
mut color := Color.red
|
mut color := Color.red
|
||||||
assert color == Color.red
|
assert color == .red
|
||||||
color = .green
|
color = .green
|
||||||
assert color == Color.green
|
assert color == .green
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_in() {
|
fn test_in() {
|
||||||
|
@ -133,22 +133,22 @@ fn new_digest(hash crypto.Hash) &Digest {
|
|||||||
|
|
||||||
// new returns a new Digest (implementing hash.Hash) computing the SHA-512 checksum.
|
// new returns a new Digest (implementing hash.Hash) computing the SHA-512 checksum.
|
||||||
pub fn new() &Digest {
|
pub fn new() &Digest {
|
||||||
return new_digest(crypto.Hash.sha512)
|
return new_digest(.sha512)
|
||||||
}
|
}
|
||||||
|
|
||||||
// new512_224 returns a new Digest (implementing hash.Hash) computing the SHA-512/224 checksum.
|
// new512_224 returns a new Digest (implementing hash.Hash) computing the SHA-512/224 checksum.
|
||||||
fn new512_224() &Digest {
|
fn new512_224() &Digest {
|
||||||
return new_digest(crypto.Hash.sha512_224)
|
return new_digest(.sha512_224)
|
||||||
}
|
}
|
||||||
|
|
||||||
// new512_256 returns a new Digest (implementing hash.Hash) computing the SHA-512/256 checksum.
|
// new512_256 returns a new Digest (implementing hash.Hash) computing the SHA-512/256 checksum.
|
||||||
fn new512_256() &Digest {
|
fn new512_256() &Digest {
|
||||||
return new_digest(crypto.Hash.sha512_256)
|
return new_digest(.sha512_256)
|
||||||
}
|
}
|
||||||
|
|
||||||
// new384 returns a new Digest (implementing hash.Hash) computing the SHA-384 checksum.
|
// new384 returns a new Digest (implementing hash.Hash) computing the SHA-384 checksum.
|
||||||
fn new384() &Digest {
|
fn new384() &Digest {
|
||||||
return new_digest(crypto.Hash.sha384)
|
return new_digest(.sha384)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (d mut Digest) write(p_ []byte) ?int {
|
fn (d mut Digest) write(p_ []byte) ?int {
|
||||||
@ -244,7 +244,7 @@ fn (d mut Digest) checksum() []byte {
|
|||||||
binary.big_endian_put_u64(mut digest[24..], d.h[3])
|
binary.big_endian_put_u64(mut digest[24..], d.h[3])
|
||||||
binary.big_endian_put_u64(mut digest[32..], d.h[4])
|
binary.big_endian_put_u64(mut digest[32..], d.h[4])
|
||||||
binary.big_endian_put_u64(mut digest[40..], d.h[5])
|
binary.big_endian_put_u64(mut digest[40..], d.h[5])
|
||||||
if d.function != crypto.Hash.sha384 {
|
if d.function != .sha384 {
|
||||||
binary.big_endian_put_u64(mut digest[48..], d.h[6])
|
binary.big_endian_put_u64(mut digest[48..], d.h[6])
|
||||||
binary.big_endian_put_u64(mut digest[56..], d.h[7])
|
binary.big_endian_put_u64(mut digest[56..], d.h[7])
|
||||||
}
|
}
|
||||||
@ -254,14 +254,14 @@ fn (d mut Digest) checksum() []byte {
|
|||||||
|
|
||||||
// sum512 returns the SHA512 checksum of the data.
|
// sum512 returns the SHA512 checksum of the data.
|
||||||
pub fn sum512(data []byte) []byte {
|
pub fn sum512(data []byte) []byte {
|
||||||
mut d := new_digest(crypto.Hash.sha512)
|
mut d := new_digest(.sha512)
|
||||||
d.write(data)
|
d.write(data)
|
||||||
return d.checksum()
|
return d.checksum()
|
||||||
}
|
}
|
||||||
|
|
||||||
// sum384 returns the SHA384 checksum of the data.
|
// sum384 returns the SHA384 checksum of the data.
|
||||||
pub fn sum384(data []byte) []byte {
|
pub fn sum384(data []byte) []byte {
|
||||||
mut d := new_digest(crypto.Hash.sha384)
|
mut d := new_digest(.sha384)
|
||||||
d.write(data)
|
d.write(data)
|
||||||
sum := d.checksum()
|
sum := d.checksum()
|
||||||
mut sum384 := [byte(0)].repeat(size384)
|
mut sum384 := [byte(0)].repeat(size384)
|
||||||
@ -271,7 +271,7 @@ pub fn sum384(data []byte) []byte {
|
|||||||
|
|
||||||
// sum512_224 returns the Sum512/224 checksum of the data.
|
// sum512_224 returns the Sum512/224 checksum of the data.
|
||||||
pub fn sum512_224(data []byte) []byte {
|
pub fn sum512_224(data []byte) []byte {
|
||||||
mut d := new_digest(crypto.Hash.sha512_224)
|
mut d := new_digest(.sha512_224)
|
||||||
d.write(data)
|
d.write(data)
|
||||||
sum := d.checksum()
|
sum := d.checksum()
|
||||||
mut sum224 := [byte(0)].repeat(size224)
|
mut sum224 := [byte(0)].repeat(size224)
|
||||||
@ -281,7 +281,7 @@ pub fn sum512_224(data []byte) []byte {
|
|||||||
|
|
||||||
// Sum512_256 returns the Sum512/256 checksum of the data.
|
// Sum512_256 returns the Sum512/256 checksum of the data.
|
||||||
pub fn sum512_256(data []byte) []byte {
|
pub fn sum512_256(data []byte) []byte {
|
||||||
mut d := new_digest(crypto.Hash.sha512_256)
|
mut d := new_digest(.sha512_256)
|
||||||
d.write(data)
|
d.write(data)
|
||||||
sum := d.checksum()
|
sum := d.checksum()
|
||||||
mut sum256 := [byte(0)].repeat(size256)
|
mut sum256 := [byte(0)].repeat(size256)
|
||||||
|
Loading…
Reference in New Issue
Block a user