1
0
mirror of https://github.com/KarolS/millfork.git synced 2026-04-21 09:16:34 +00:00

Add pstring module

This commit is contained in:
Karol Stasiak
2020-04-06 00:44:20 +02:00
parent 4485c9479e
commit 320b84edb9
12 changed files with 162 additions and 6 deletions
+11 -2
View File
@@ -23,17 +23,26 @@ void print_failure() {
}
void assert_equal(word expected, word actual) {
current_test_number += 1
if actual != expected {
print_failure()
putstrz("Expected:"z)
putstrz("Expected: "z)
putword(expected)
putstrz("Actual:"z)
putstrz(" Actual: "z)
putword(actual)
new_line()
readkey()
}
}
void assert_true(bool result) {
current_test_number += 1
if not(result) {
print_failure()
readkey()
}
}
void begin_test() {
}
+7
View File
@@ -1,8 +1,15 @@
import test_fibonacci
import test_pstring
import test_string
void main() {
ensure_mixedcase()
test_fibonacci()
test_string()
test_pstring()
new_line()
putstrz("Total failures: "z)
putword(failure_count)
}
+1 -1
View File
@@ -15,4 +15,4 @@ void test_fibonacci() {
assert_equal(2, fib(2))
assert_equal(3, fib(3))
assert_equal(5, fib(4))
}
}
+23
View File
@@ -0,0 +1,23 @@
import pstring
import framework
void test_pstring() {
array buffer[256]
start_suite("pstring"z)
assert_equal(0, pstrcmp("a"p, "a"p))
assert_equal(-1, pstrcmp("a"p, "b"p))
assert_equal(-1, pstrcmp("a"p, "ab"p))
assert_equal(1, pstrcmp("b"p, "a"p))
assert_equal(1, pstrcmp("ab"p, "a"p))
pstrcopy(buffer, "test"p)
assert_equal(4, pstrlen(buffer))
assert_equal(0, pstrcmp("test"p, buffer))
pstrappend(buffer, "hello"p)
assert_equal(9, pstrlen(buffer))
assert_equal(0, pstrcmp("testhello"p, buffer))
assert_equal(1234, pstr2word("1234"p))
}
+23
View File
@@ -0,0 +1,23 @@
import string
import framework
void test_string() {
array buffer[256]
start_suite("string"z)
assert_equal(0, strzcmp("a"z, "a"z))
assert_equal(-1, strzcmp("a"z, "b"z))
assert_equal(-1, strzcmp("a"z, "ab"z))
assert_equal(1, strzcmp("b"z, "a"z))
assert_equal(1, strzcmp("ab"z, "a"z))
strzcopy(buffer, "test"z)
assert_equal(4, strzlen(buffer))
assert_equal(0, strzcmp("test"z, buffer))
strzappend(buffer, "hello"z)
assert_equal(9, strzlen(buffer))
assert_equal(0, strzcmp("testhello"z, buffer))
assert_equal(1234, strz2word("1234"z))
}