mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Add bitsizeof to Builtins (#2376)
* Add `bitsizeof` to Builtins --------- Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
This commit is contained in:
@@ -184,3 +184,22 @@ fn void test_ct_clz()
|
||||
assert(@clz((uint128)0x87) == 120);
|
||||
assert(@clz((char)(0x44 - 0x40)) == 5);
|
||||
}
|
||||
|
||||
fn void test_bitsizeof()
|
||||
{
|
||||
assert(bitsizeof(uint128) == 128);
|
||||
assert(bitsizeof(ulong) == 64);
|
||||
assert(bitsizeof(int) == 32);
|
||||
assert(bitsizeof(short) == 16);
|
||||
assert(bitsizeof(char) == 8);
|
||||
assert(bitsizeof(char[200]) == 1600);
|
||||
|
||||
// Checks that they may be converted
|
||||
int x = bitsizeof(char);
|
||||
int y = @bitsizeof(1);
|
||||
|
||||
assert(@bitsizeof((char)0x07) == 8);
|
||||
assert(@bitsizeof(0x1000ul) == 64);
|
||||
assert(@bitsizeof(0) == 32);
|
||||
assert(@bitsizeof((char[*])"abcdefghi") == 72);
|
||||
}
|
||||
Reference in New Issue
Block a user