#
#  PRE: if return
#
string test_string
octets test_octets
uint32 test_int

test_string = "hello world"
test_octets = 0x01234567
test_int = 123456

if !(%substr(%{test_string}, 1, 3) == 'ell') {
	test_fail
}

if !(%substr(%{test_string}, 0, 3) == 'hel') {
	test_fail
}

if !(%substr(%{test_string}, 5) == ' world') {
	test_fail
}

if !(%substr(%{test_string}, -3) == 'rld') {
	test_fail
}

if !(%substr(%{test_string}, -20) == 'hello world') {
	test_fail
}

if !(%substr(%{test_string}, -4, 2) == 'or') {
	test_fail
}

if !(%substr(%{test_string}, -10, -3) == 'ello wo') {
	test_fail
}

if (%substr(%{test_string}, 20)) {
	test_fail
}

if (%substr(%{test_string}, 5, -7)) {
	test_fail
}

if !(%substr(%{test_octets}, 1, 2) == 0x2345) {
	test_fail
}

if !(%substr(%{test_int}, 1, 2) == '23') {
	test_fail
}

success
