Default fourcc! to big-endian.

It was decided that a consistent result across platforms would be the
most useful and least surprising. A "target" option has been added to
get the old behaviour of using the target platform's endianess.
This commit is contained in:
Yuri Kunde Schlesner 2014-02-06 17:41:49 -02:00 committed by Derek Guenther
parent 97078d43b2
commit 6381daab77
2 changed files with 12 additions and 8 deletions

View file

@ -19,22 +19,25 @@
extern mod fourcc;
static static_val: u32 = fourcc!("foo ");
static static_val_le: u32 = fourcc!("foo ", little);
static static_val_be: u32 = fourcc!("foo ", big);
static static_val_le: u32 = fourcc!("foo ", little);
static static_val_target: u32 = fourcc!("foo ", target);
fn main() {
let val = fourcc!("foo ");
let exp = if cfg!(target_endian = "big") { 0x666f6f20u32 } else { 0x206f6f66u32 };
assert_eq!(val, exp);
let val = fourcc!("foo ", big);
assert_eq!(val, 0x666f6f20u32);
assert_eq!(val, fourcc!("foo "));
let val = fourcc!("foo ", little);
assert_eq!(val, 0x206f6f66u32);
let val = fourcc!("foo ", target);
let exp = if cfg!(target_endian = "big") { 0x666f6f20u32 } else { 0x206f6f66u32 };
assert_eq!(static_val, exp);
assert_eq!(static_val_le, 0x206f6f66u32);
assert_eq!(val, exp);
assert_eq!(static_val_be, 0x666f6f20u32);
assert_eq!(static_val, static_val_be);
assert_eq!(static_val_le, 0x206f6f66u32);
let exp = if cfg!(target_endian = "big") { 0x666f6f20u32 } else { 0x206f6f66u32 };
assert_eq!(static_val_target, exp);
}