hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

+test.ha (1370B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 @test fn sizes() void = {
      5 	static assert(size(char) == size(schar));
      6 	static assert(size(char) == size(uchar));
      7 	static assert(size(char) == 1);
      8 	static assert(size(short) == size(ushort));
      9 	static assert(size(long) == size(ulong));
     10 	static assert(size(longlong) == size(ulonglong));
     11 	static assert(size(intmax) == size(uintmax));
     12 	static assert(size(intptr) == size(uintptr));
     13 	static assert(size(ssize) == size(size));
     14 	static assert(size(short) <= size(int));
     15 	static assert(size(long) >= 4);
     16 	static assert(size(longlong) >= 8);
     17 	static assert(size(short) >= size(char));
     18 	static assert(size(int) >= size(short));
     19 	static assert(size(long) >= size(int));
     20 	static assert(size(longlong) >= size(long));
     21 
     22 	static assert(align(char) == align(schar));
     23 	static assert(align(char) == align(uchar));
     24 	static assert(align(char) == 1);
     25 	static assert(align(short) == align(ushort));
     26 	static assert(align(long) == align(ulong));
     27 	static assert(align(longlong) == align(ulonglong));
     28 	static assert(align(intmax) == align(uintmax));
     29 	static assert(align(intptr) == align(uintptr));
     30 	static assert(align(ssize) == align(size));
     31 };
     32 
     33 @test fn strings() void = {
     34 	let s = fromstr("hello!");
     35 	defer free(s);
     36 	assert(tostr(s)! == "hello!");
     37 	let s = nulstr("hello!\0");
     38 	assert(tostr(s)! == "hello!");
     39 };