Poorman's testing framework and i don't remember what
parent
35b97557e7
commit
1777a98f62
@ -0,0 +1,55 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* assert.h */
|
||||
/* */
|
||||
/* Diagnostics */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2000 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
/* warranty. In no event will the authors be held liable for any damages */
|
||||
/* arising from the use of this software. */
|
||||
/* */
|
||||
/* Permission is granted to anyone to use this software for any purpose, */
|
||||
/* including commercial applications, and to alter it and redistribute it */
|
||||
/* freely, subject to the following restrictions: */
|
||||
/* */
|
||||
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||
/* claim that you wrote the original software. If you use this software */
|
||||
/* in a product, an acknowledgment in the product documentation would be */
|
||||
/* appreciated but is not required. */
|
||||
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||
/* be misrepresented as being the original software. */
|
||||
/* 3. This notice may not be removed or altered from any source */
|
||||
/* distribution. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifndef _ASSERT_H
|
||||
#define _ASSERT_H
|
||||
|
||||
|
||||
|
||||
#undef assert
|
||||
#ifdef NDEBUG
|
||||
# define assert(expr)
|
||||
#else
|
||||
extern void _afailed (const char*, unsigned);
|
||||
# define assert(expr) ((expr)? (void)0 : _afailed(__FILE__, __LINE__))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* End of assert.h */
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Ullrich von Bassewitz, 11.08.1998
|
||||
*
|
||||
* Hex conversion table. Must be in C since the compiler will convert
|
||||
* to the correct character set for the target platform.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const unsigned char _hextab [16] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
;
|
||||
; File generated by cc65 v 2.13.3
|
||||
;
|
||||
.fopt compiler,"cc65 v 2.13.3"
|
||||
.setcpu "65C02"
|
||||
.smart on
|
||||
.autoimport on
|
||||
.case on
|
||||
.debuginfo on
|
||||
.importzp sp, sreg, regsave, regbank, tmp1, ptr1, ptr2
|
||||
.macpack longbranch
|
||||
.dbg file, "_hextab.c", 306, 965299531
|
||||
.export __hextab
|
||||
|
||||
.segment "RODATA"
|
||||
|
||||
__hextab:
|
||||
.byte $30
|
||||
.byte $31
|
||||
.byte $32
|
||||
.byte $33
|
||||
.byte $34
|
||||
.byte $35
|
||||
.byte $36
|
||||
.byte $37
|
||||
.byte $38
|
||||
.byte $39
|
||||
.byte $41
|
||||
.byte $42
|
||||
.byte $43
|
||||
.byte $44
|
||||
.byte $45
|
||||
.byte $46
|
||||
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
#include <console.h>
|
@ -0,0 +1,59 @@
|
||||
#include <redbus.h>
|
||||
#include <console.h>
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#define RB 0x0300
|
||||
#define LSTREAM 47
|
||||
#define SCREEN_W 80
|
||||
#define SCREEN_H 50
|
||||
|
||||
Console* con;
|
||||
|
||||
void blit(char command, char x, char y, char xo, char yo, char w, char h) {
|
||||
con->blit_start_x = x;
|
||||
con->blit_start_y = y;
|
||||
con->blit_offset_x = xo;
|
||||
con->blit_offset_y = yo;
|
||||
con->blit_width = w;
|
||||
con->blit_height = h;
|
||||
con->blit_mode = command;
|
||||
while(con->blit_mode != 0) ; //WAI
|
||||
}
|
||||
|
||||
void linefeed() {
|
||||
scroll(0,1,0,0,SCREEN_W,SCREEN_H-3);
|
||||
fill(0x20,0,LSTREAM,SCREEN_W,1);
|
||||
}
|
||||
|
||||
unsigned char cursor = 0;
|
||||
|
||||
void print(char* buffer) {
|
||||
unsigned char i = 0;
|
||||
|
||||
if(buffer[0] == 0) return;
|
||||
|
||||
con->line = LSTREAM;
|
||||
|
||||
if(cursor == 0) linefeed();
|
||||
|
||||
while(buffer[i] != 0 && i < 128) {
|
||||
if(buffer[i] == '\n' || cursor == 80) {
|
||||
cursor = 0;
|
||||
linefeed();
|
||||
} else {
|
||||
con->display[cursor] = buffer[i];
|
||||
++cursor;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
if(i < 128)
|
||||
cursor = 0;
|
||||
}
|
||||
|
||||
void init_tests() {
|
||||
rb_set_window((void*)RB);
|
||||
con = (Console*)RB;
|
||||
rb_enable();
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
void init_tests();
|
||||
void print(char* buffer);
|
||||
|
||||
#define TEST(NAME, COND) print(NAME); print(#COND); if((COND)) print("PASS\n"); else print("FAIL\n")
|
@ -0,0 +1,304 @@
|
||||
;
|
||||
; File generated by cc65 v 2.13.3
|
||||
;
|
||||
.fopt compiler,"cc65 v 2.13.3"
|
||||
.setcpu "65C02"
|
||||
.smart on
|
||||
.autoimport on
|
||||
.case on
|
||||
.debuginfo off
|
||||
.importzp sp, sreg, regsave, regbank, tmp1, ptr1, ptr2
|
||||
.macpack longbranch
|
||||
.import _rb_enable
|
||||
.import _rb_set_window
|
||||
.export _init_tests
|
||||
.export _print
|
||||
.export _con
|
||||
.export _blit
|
||||
.export _linefeed
|
||||
.export _cursor
|
||||
|
||||
.segment "DATA"
|
||||
|
||||
_cursor:
|
||||
.byte $00
|
||||
|
||||
.segment "BSS"
|
||||
|
||||
_con:
|
||||
.res 2,$00
|
||||
|
||||
; ---------------------------------------------------------------
|
||||
; void __near__ init_tests (void)
|
||||
; ---------------------------------------------------------------
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
.proc _init_tests: near
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
ldx #$03
|
||||
lda #$00
|
||||
jsr _rb_set_window
|
||||
ldx #$03
|
||||
lda #$00
|
||||
sta _con
|
||||
stx _con+1
|
||||
jsr _rb_enable
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
; ---------------------------------------------------------------
|
||||
; void __near__ print (__near__ unsigned char*)
|
||||
; ---------------------------------------------------------------
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
.proc _print: near
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
lda #$00
|
||||
jsr pusha
|
||||
ldy #$02
|
||||
jsr ldaxysp
|
||||
ldy #$00
|
||||
jsr ldauidx
|
||||
cmp #$00
|
||||
jsr booleq
|
||||
jeq L0029
|
||||
jmp L0045
|
||||
L0029: lda _con
|
||||
ldx _con+1
|
||||
jsr pushax
|
||||
ldx #$00
|
||||
lda #$2F
|
||||
ldy #$00
|
||||
jsr staspidx
|
||||
ldx #$00
|
||||
lda _cursor
|
||||
cmp #$00
|
||||
jsr booleq
|
||||
jeq L002E
|
||||
jsr _linefeed
|
||||
L002E: ldy #$02
|
||||
jsr ldaxysp
|
||||
jsr pushax
|
||||
ldy #$02
|
||||
ldx #$00
|
||||
lda (sp),y
|
||||
jsr tosaddax
|
||||
ldy #$00
|
||||
jsr ldauidx
|
||||
cmp #$00
|
||||
jsr boolne
|
||||
jeq L0035
|
||||
ldy #$00
|
||||
ldx #$00
|
||||
lda (sp),y
|
||||
cmp #$80
|
||||
jsr boolult
|
||||
jne L0033
|
||||
L0035: ldx #$00
|
||||
lda #$00
|
||||
jeq L0036
|
||||
L0033: ldx #$00
|
||||
lda #$01
|
||||
L0036: jeq L0032
|
||||
ldy #$02
|
||||
jsr ldaxysp
|
||||
jsr pushax
|
||||
ldy #$02
|
||||
ldx #$00
|
||||
lda (sp),y
|
||||
jsr tosaddax
|
||||
ldy #$00
|
||||
jsr ldauidx
|
||||
cmp #$0A
|
||||
jsr booleq
|
||||
jne L0038
|
||||
ldx #$00
|
||||
lda _cursor
|
||||
cmp #$50
|
||||
jsr booleq
|
||||
jne L0038
|
||||
ldx #$00
|
||||
lda #$00
|
||||
jeq L003A
|
||||
L0038: ldx #$00
|
||||
lda #$01
|
||||
L003A: jeq L0037
|
||||
ldx #$00
|
||||
lda #$00
|
||||
sta _cursor
|
||||
jsr _linefeed
|
||||
jmp L003E
|
||||
L0037: lda _con
|
||||
ldx _con+1
|
||||
ldy #$10
|
||||
jsr incaxy
|
||||
jsr pushax
|
||||
ldx #$00
|
||||
lda _cursor
|
||||
jsr tosaddax
|
||||
jsr pushax
|
||||
ldy #$04
|
||||
jsr ldaxysp
|
||||
jsr pushax
|
||||
ldy #$04
|
||||
ldx #$00
|
||||
lda (sp),y
|
||||
jsr tosaddax
|
||||
ldy #$00
|
||||
jsr ldauidx
|
||||
ldy #$00
|
||||
jsr staspidx
|
||||
ldx #$00
|
||||
inc _cursor
|
||||
lda _cursor
|
||||
L003E: ldy #$00
|
||||
ldx #$00
|
||||
clc
|
||||
lda #$01
|
||||
adc (sp),y
|
||||
sta (sp),y
|
||||
jmp L002E
|
||||
L0032: ldy #$00
|
||||
ldx #$00
|
||||
lda (sp),y
|
||||
cmp #$80
|
||||
jsr boolult
|
||||
jeq L0045
|
||||
ldx #$00
|
||||
lda #$00
|
||||
sta _cursor
|
||||
L0045: jsr incsp3
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
; ---------------------------------------------------------------
|
||||
; void __near__ blit (unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)
|
||||
; ---------------------------------------------------------------
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
.proc _blit: near
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
lda _con
|
||||
ldx _con+1
|
||||
jsr pushax
|
||||
ldy #$07
|
||||
ldx #$00
|
||||
lda (sp),y
|
||||
ldy #$08
|
||||
jsr staspidx
|
||||
lda _con
|
||||
ldx _con+1
|
||||
jsr pushax
|
||||
ldy #$06
|
||||
ldx #$00
|
||||
lda (sp),y
|
||||
ldy #$09
|
||||
jsr staspidx
|
||||
lda _con
|
||||
ldx _con+1
|
||||
jsr pushax
|
||||
ldy #$05
|
||||
ldx #$00
|
||||
lda (sp),y
|
||||
ldy #$0A
|
||||
jsr staspidx
|
||||
lda _con
|
||||
ldx _con+1
|
||||
jsr pushax
|
||||
ldy #$04
|
||||
ldx #$00
|
||||
lda (sp),y
|
||||
ldy #$0B
|
||||
jsr staspidx
|
||||
lda _con
|
||||
ldx _con+1
|
||||
jsr pushax
|
||||
ldy #$03
|
||||
ldx #$00
|
||||
lda (sp),y
|
||||
ldy #$0C
|
||||
jsr staspidx
|
||||
lda _con
|
||||
ldx _con+1
|
||||
jsr pushax
|
||||
ldy #$02
|
||||
ldx #$00
|
||||
lda (sp),y
|
||||
ldy #$0D
|
||||
jsr staspidx
|
||||
lda _con
|
||||
ldx _con+1
|
||||
jsr pushax
|
||||
ldy #$08
|
||||
ldx #$00
|
||||
lda (sp),y
|
||||
ldy #$07
|
||||
jsr staspidx
|
||||
L0012: lda _con
|
||||
ldx _con+1
|
||||
ldy #$07
|
||||
jsr ldauidx
|
||||
cmp #$00
|
||||
jsr boolne
|
||||
jeq L0013
|
||||
jmp L0012
|
||||
L0013: jsr incsp7
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
; ---------------------------------------------------------------
|
||||
; void __near__ linefeed (void)
|
||||
; ---------------------------------------------------------------
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
.proc _linefeed: near
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
lda #$03
|
||||
jsr pusha
|
||||
lda #$00
|
||||
jsr pusha
|
||||
lda #$01
|
||||
jsr pusha
|
||||
lda #$00
|
||||
jsr pusha
|
||||
lda #$00
|
||||
jsr pusha
|
||||
lda #$50
|
||||
jsr pusha
|
||||
lda #$2F
|
||||
jsr pusha
|
||||
jsr _blit
|
||||
lda #$01
|
||||
jsr pusha
|
||||
lda #$20
|
||||
jsr pusha
|
||||
lda #$00
|
||||
jsr pusha
|
||||
lda #$00
|
||||
jsr pusha
|
||||
lda #$2F
|
||||
jsr pusha
|
||||
lda #$50
|
||||
jsr pusha
|
||||
lda #$01
|
||||
jsr pusha
|
||||
jsr _blit
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
@ -1,64 +0,0 @@
|
||||
;
|
||||
; File generated by cc65 v 2.13.3
|
||||
;
|
||||
.fopt compiler,"cc65 v 2.13.3"
|
||||
.setcpu "65C02"
|
||||
.smart on
|
||||
.autoimport on
|
||||
.case on
|
||||
.debuginfo off
|
||||
.importzp sp, sreg, regsave, regbank, tmp1, ptr1, ptr2
|
||||
.macpack longbranch
|
||||
.forceimport __STARTUP__
|
||||
.import _rb_enable
|
||||
.import _rb_set_window
|
||||
.import _rb_map_device
|
||||
.export _main
|
||||
|
||||
; ---------------------------------------------------------------
|
||||
; void __near__ main (void)
|
||||
; ---------------------------------------------------------------
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
.proc _main: near
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
jsr decsp2
|
||||
ldx #$03
|
||||
lda #$00
|
||||
jsr _rb_set_window
|
||||
lda #$01
|
||||
jsr _rb_map_device
|
||||
jsr _rb_enable
|
||||
ldx #$03
|
||||
lda #$00
|
||||
ldy #$00
|
||||
jsr staxysp
|
||||
ldy #$01
|
||||
jsr ldaxysp
|
||||
jsr pushax
|
||||
ldx #$00
|
||||
lda #$02
|
||||
ldy #$03
|
||||
jsr staspidx
|
||||
ldy #$01
|
||||
jsr ldaxysp
|
||||
jsr pushax
|
||||
ldx #$00
|
||||
lda #$58
|
||||
ldy #$10
|
||||
jsr staspidx
|
||||
ldy #$01
|
||||
jsr ldaxysp
|
||||
jsr pushax
|
||||
ldx #$00
|
||||
lda #$D9
|
||||
ldy #$11
|
||||
jsr staspidx
|
||||
jsr incsp2
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
@ -0,0 +1,48 @@
|
||||
#include <stdlib.h>
|
||||
#include "test.h"
|
||||
|
||||
|
||||
// void* malloc (size_t size);
|
||||
// void* calloc (size_t count, size_t size);
|
||||
// void* realloc (void* block, size_t size);
|
||||
// void free (void* block);
|
||||
// void _heapadd (void* mem, size_t size);
|
||||
// size_t _heapblocksize (const void* block);
|
||||
// size_t _heapmemavail (void);
|
||||
// size_t _heapmaxavail (void);
|
||||
// int rand (void);
|
||||
// void srand (unsigned seed);
|
||||
// void _randomize (void);
|
||||
// void abort (void);
|
||||
//// int abs (int val);
|
||||
// long labs (long val);
|
||||
//// int atoi (const char* s);
|
||||
// long atol (const char* s);
|
||||
// int atexit (void (*exitfunc) (void));
|
||||
// void* bsearch (const void* key, const void* base, size_t n, size_t size, int (*cmp) (const void*, const void*));
|
||||
// div_t div (int numer, int denom);
|
||||
// void exit (int ret);
|
||||
// char* getenv (const char* name);
|
||||
// void qsort (void* base, size_t count, size_t size, int (*compare) (const void*, const void*));
|
||||
// long strtol (const char* nptr, char** endptr, int base);
|
||||
// unsigned long strtoul (const char* nptr, char** endptr, int base);
|
||||
// int system (const char* s);
|
||||
// void _swap (void* p, void* q, size_t size);
|
||||
//// char* itoa (int val, char* buf, int radix);
|
||||
// char* utoa (unsigned val, char* buf, int radix);
|
||||
// char* ltoa (long val, char* buf, int radix);
|
||||
// char* ultoa (unsigned long val, char* buf, int radix);
|
||||
// int putenv (char* s);
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
char temp[5];
|
||||
|
||||
init_tests();
|
||||
|
||||
TEST("abs", 1 == abs(-1));
|
||||
TEST("abs", 0xFAF == abs(0xFAF));
|
||||
|
||||
TEST("itoa-atoi", 257 == atoi(itoa(257, temp, 10)));
|
||||
}
|
Loading…
Reference in New Issue