2019-11-23 17:35:57 +01:00
|
|
|
module main
|
2019-11-26 04:12:37 +01:00
|
|
|
|
2022-04-15 17:25:45 +02:00
|
|
|
import builtin.linux_bare.old..checks.forkedtest
|
|
|
|
|
|
|
|
fn check_string_eq() {
|
|
|
|
assert 'monkey' != 'rat'
|
|
|
|
some_animal := 'a bird'
|
|
|
|
assert some_animal == 'a bird'
|
2019-11-23 17:35:57 +01:00
|
|
|
}
|
|
|
|
|
2019-11-26 04:12:37 +01:00
|
|
|
fn check_i64_tos() {
|
2022-04-15 17:25:45 +02:00
|
|
|
buffer0 := []u8{len: (128)}
|
2019-12-08 11:44:52 +01:00
|
|
|
buffer := byteptr(buffer0.data)
|
2019-12-07 20:25:19 +01:00
|
|
|
|
2019-11-26 04:12:37 +01:00
|
|
|
s0 := i64_tos(buffer, 70, 140, 10)
|
2022-04-15 17:25:45 +02:00
|
|
|
assert s0 == '140'
|
2019-11-26 04:12:37 +01:00
|
|
|
|
|
|
|
s1 := i64_tos(buffer, 70, -160, 10)
|
2022-04-15 17:25:45 +02:00
|
|
|
assert s1 == '-160'
|
2019-11-26 04:12:37 +01:00
|
|
|
|
|
|
|
s2 := i64_tos(buffer, 70, 65537, 16)
|
2022-04-15 17:25:45 +02:00
|
|
|
assert s2 == '10001'
|
2019-11-26 04:12:37 +01:00
|
|
|
|
|
|
|
s3 := i64_tos(buffer, 70, -160000, 10)
|
2022-04-15 17:25:45 +02:00
|
|
|
assert s3 == '-160000'
|
2019-12-08 11:44:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fn check_i64_str() {
|
2022-04-15 17:25:45 +02:00
|
|
|
assert '141' == i64_str(141, 10)
|
|
|
|
assert '-161' == i64_str(-161, 10)
|
|
|
|
assert '10002' == i64_str(65538, 16)
|
|
|
|
assert '-160001' == i64_str(-160001, 10)
|
2019-12-08 11:44:52 +01:00
|
|
|
}
|
2019-12-07 20:25:19 +01:00
|
|
|
|
2019-12-08 11:44:52 +01:00
|
|
|
fn check_str_clone() {
|
2022-04-15 17:25:45 +02:00
|
|
|
a := i64_str(1234, 10)
|
2019-12-08 11:44:52 +01:00
|
|
|
b := a.clone()
|
|
|
|
assert a == b
|
2022-04-15 17:25:45 +02:00
|
|
|
c := i64_str(-6789, 10).clone()
|
|
|
|
assert c == '-6789'
|
|
|
|
}
|
|
|
|
|
|
|
|
fn check_string_add_works() {
|
|
|
|
abc := 'abc'
|
|
|
|
combined := 'a' + 'b' + 'c'
|
|
|
|
assert abc.len == combined.len
|
|
|
|
assert abc[0] == combined[0]
|
|
|
|
assert abc[1] == combined[1]
|
|
|
|
assert abc[2] == combined[2]
|
|
|
|
assert abc[0] == `a`
|
|
|
|
assert abc == combined
|
2019-11-26 04:12:37 +01:00
|
|
|
}
|
|
|
|
|
2022-04-15 17:25:45 +02:00
|
|
|
fn main() {
|
2019-12-07 20:25:19 +01:00
|
|
|
mut fails := 0
|
2022-04-15 17:25:45 +02:00
|
|
|
fails += forkedtest.normal_run(check_string_eq, 'check_string_eq')
|
|
|
|
fails += forkedtest.normal_run(check_i64_tos, 'check_i64_tos')
|
|
|
|
fails += forkedtest.normal_run(check_i64_str, 'check_i64_str')
|
|
|
|
fails += forkedtest.normal_run(check_str_clone, 'check_str_clone')
|
|
|
|
fails += forkedtest.normal_run(check_string_add_works, 'check_string_add_works')
|
2019-12-07 20:25:19 +01:00
|
|
|
assert fails == 0
|
2019-11-23 17:35:57 +01:00
|
|
|
sys_exit(0)
|
|
|
|
}
|