Fixed indentation

This commit is contained in:
IrgendwerA8
2017-02-26 22:36:19 +01:00
parent c240d42a9e
commit 3d28f5ca90
4 changed files with 66 additions and 67 deletions

View File

@@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 2017 Christian Krueger */ /* (C) 2017 Christian Krueger */
/* */ /* */
/* This software is provided 'as-is', without any expressed or implied */ /* This software is provided 'as-is', without any expressed or implied */
/* warranty. In no event will the authors be held liable for any damages */ /* warranty. In no event will the authors be held liable for any damages */
@@ -37,49 +37,49 @@
#define COMMA , #define COMMA ,
#endif #endif
#define TEST int main(void) \ #define TEST int main(void) \
{\ {\
printf("%s: ",__FILE__); printf("%s: ",__FILE__);
#define ENDTEST printf("Passed\n"); \ #define ENDTEST printf("Passed\n"); \
return EXIT_SUCCESS; \ return EXIT_SUCCESS; \
} }
#define ASSERT_IsTrue(a,b) if (!(a)) \ #define ASSERT_IsTrue(a,b) if (!(a)) \
{\ {\
printf("Fail at line %d:\n",__LINE__);\ printf("Fail at line %d:\n",__LINE__);\
printf(b);\ printf(b);\
printf("\n");\ printf("\n");\
printf("Expected status should be true but wasn't!\n");\ printf("Expected status should be true but wasn't!\n");\
exit(EXIT_FAILURE);\ exit(EXIT_FAILURE);\
} }
#define ASSERT_IsFalse(a,b) if ((a)) \ #define ASSERT_IsFalse(a,b) if ((a)) \
{\ {\
printf("Fail at line %d:\n",__LINE__);\ printf("Fail at line %d:\n",__LINE__);\
printf(b);\ printf(b);\
printf("\n");\ printf("\n");\
printf("Expected status should be false but wasn't!\n");\ printf("Expected status should be false but wasn't!\n");\
exit(EXIT_FAILURE);\ exit(EXIT_FAILURE);\
} }
#define ASSERT_AreEqual(a,b,c,d) if ((a) != (b)) \ #define ASSERT_AreEqual(a,b,c,d) if ((a) != (b)) \
{\ {\
printf("Fail at line %d:\n",__LINE__);\ printf("Fail at line %d:\n",__LINE__);\
printf(d);\ printf(d);\
printf("\n");\ printf("\n");\
printf("Expected value: "c", but is "c"!\n", (a), (b));\ printf("Expected value: "c", but is "c"!\n", (a), (b));\
exit(EXIT_FAILURE);\ exit(EXIT_FAILURE);\
} }
#define ASSERT_AreNotEqual(a,b,c,d) if ((a) == (b)) \ #define ASSERT_AreNotEqual(a,b,c,d) if ((a) == (b)) \
{\ {\
printf("Fail at line %d:\n",__LINE__);\ printf("Fail at line %d:\n",__LINE__);\
printf(d);\ printf(d);\
printf("\n");\ printf("\n");\
printf("Expected value not: "c", but is "c"!\n", (a), (b));\ printf("Expected value not: "c", but is "c"!\n", (a), (b));\
exit(EXIT_FAILURE);\ exit(EXIT_FAILURE);\
} }
/* End of unittest.h */ /* End of unittest.h */
#endif #endif

View File

@@ -10,38 +10,37 @@
.importzp ptr1, ptr2, tmp3 .importzp ptr1, ptr2, tmp3
_strcat: _strcat:
sta ptr1 ; Save src sta ptr1 ; Save src
stx ptr1+1 stx ptr1+1
jsr popax ; Get dest jsr popax ; Get dest
sta tmp3 ; Remember for function return sta tmp3 ; Remember for function return
tay tay
lda #0 lda #0
sta ptr2 ; access from page start, y contains low byte sta ptr2 ; access from page start, y contains low byte
stx ptr2+1 stx ptr2+1
findEndOfDest: findEndOfDest:
lda (ptr2),y lda (ptr2),y
beq endOfDestFound beq endOfDestFound
iny iny
bne findEndOfDest bne findEndOfDest
inc ptr2+1 inc ptr2+1
bne findEndOfDest bne findEndOfDest
endOfDestFound: endOfDestFound:
sty ptr2 ; advance pointer to last y position sty ptr2 ; advance pointer to last y position
ldy #0 ; reset new y-offset ldy #0 ; reset new y-offset
copyByte: copyByte:
lda (ptr1),y lda (ptr1),y
sta (ptr2),y sta (ptr2),y
beq done beq done
iny iny
bne copyByte bne copyByte
inc ptr1+1 inc ptr1+1
inc ptr2+1 inc ptr2+1
bne copyByte ; like bra here bne copyByte ; like bra here
; return pointer to dest ; return pointer to dest
done: lda tmp3 ; X does still contain high byte done: lda tmp3 ; X does still contain high byte
rts rts

View File

@@ -3,7 +3,7 @@
#define SourceStringSize 257 // test correct page passing (>256) #define SourceStringSize 257 // test correct page passing (>256)
static char SourceString[SourceStringSize+1]; // +1 room for terminating null static char SourceString[SourceStringSize+1]; // +1 room for terminating null
static char DestinationString[2*SourceStringSize+1]; // will contain two times the source buffer static char DestinationString[2*SourceStringSize+1]; // will contain two times the source buffer
@@ -48,7 +48,7 @@ TEST
unsigned position = j*SourceStringSize+i; unsigned position = j*SourceStringSize+i;
unsigned current = DestinationString[position]; unsigned current = DestinationString[position];
unsigned expected = (i%128)+1; unsigned expected = (i%128)+1;
ASSERT_AreEqual(expected, current, "%u", "Unexpected destination buffer contents at position %u!\n" COMMA position); ASSERT_AreEqual(expected, current, "%u", "Unexpected destination buffer contents at position %u!\n" COMMA position);
} }
} }
ENDTEST ENDTEST

View File

@@ -1,7 +1,7 @@
#include <unittest.h> #include <unittest.h>
#include <string.h> #include <string.h>
static char TestString[] = "01234567890123456789"; // two times the same string static char TestString[] = "01234567890123456789"; // two times the same string
static char Found[256]; static char Found[256];
TEST TEST
@@ -10,7 +10,7 @@ TEST
unsigned i; unsigned i;
char* p; char* p;
len = strlen(TestString)/2; // test only one half of the string, to find last appearance len = strlen(TestString)/2; // test only one half of the string, to find last appearance
/* Search for all characters in the string, including the terminator */ /* Search for all characters in the string, including the terminator */
for (i = 0; i < len; ++i) for (i = 0; i < len; ++i)