/
vit1251
/
cmm
Обзор
Документация
Войти
/
vit1251
/
cmm
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
examples/assert-example.cmm
33 строки
846 B
Vitold S
update
09 авг 2026, 02:25
09 авг 2026, 02:25
a36ae1e
Код
Авторство
О чём код?
// assert_test — демонстрация assert: проверка CRC32, сравнение строк и арифметики use libc; use assert; use compress/zlib; fn test_crc32() -> void { let buf: *u8 = "hello"; let crc: u64 = crc32(0, buf, 5); assert(crc == 0x3610a686, "CRC32 of 'hello' should match"); } fn test_arithmetic() -> void { let a: i32 = 10; let b: i32 = 20; let sum: i32 = a.wrapping_add(b); assert(sum == 30, "10 + 20 should be 30"); assert(a.wrapping_mul(b) == 200, "10 * 20 should be 200"); } fn test_strings() -> void { let s1: *u8 = "abc"; let s2: *u8 = "abc"; assert(strcmp(s1, s2) == 0, "'abc' == 'abc' should match"); } fn main() -> i32 { puts("running tests..."); test_crc32(); test_arithmetic(); test_strings(); puts("all tests passed"); 0 }