mirror of
https://github.com/cc65/cc65.git
synced 2024-06-01 13:41:34 +00:00
reworked pptest1/4/5 into executable tests and moved to test/val
This commit is contained in:
parent
638e254668
commit
010ed6d729
27
test/val/pptest1.c
Normal file
27
test/val/pptest1.c
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
|
||||||
|
/* preprocessor test #1 */
|
||||||
|
|
||||||
|
#define hash_hash # ## #
|
||||||
|
#define mkstr(a) # a
|
||||||
|
#define in_between(a) mkstr(a)
|
||||||
|
#define join(c, d) in_between(c hash_hash d)
|
||||||
|
|
||||||
|
#define x "first"
|
||||||
|
#define y "second"
|
||||||
|
|
||||||
|
char p[] = join(x, y); // Comment
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
printf("expected: %s\n", "\"first\" ## \"second\"");
|
||||||
|
printf("p: %s\n", p);
|
||||||
|
if (!strcmp(p, "\"first\" ## \"second\"")) {
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
printf("all fine\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
24
test/val/pptest4.c
Normal file
24
test/val/pptest4.c
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
|
||||||
|
/* preprocessor test #4 */
|
||||||
|
|
||||||
|
#define t(x,y,z) x ## y ## z
|
||||||
|
int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),
|
||||||
|
t(10,,), t(,11,), t(,,12), t(,,) };
|
||||||
|
|
||||||
|
int e[] = { 123, 45, 67, 89, 10, 11, 12, };
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
unsigned char i;
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
for (i = 0; i < 7; ++i) {
|
||||||
|
printf("j: %d expect: %d\n", j[i], e[i]);
|
||||||
|
if (j[i] != e[i]) return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
printf("all fine\n");
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
24
test/val/pptest5.c
Normal file
24
test/val/pptest5.c
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
|
||||||
|
/* preprocessor test #5 */
|
||||||
|
|
||||||
|
#define t(x,y,z) x ## y ## z
|
||||||
|
int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),
|
||||||
|
t(10,,), t(,11,), t(,,12), t(,,) };
|
||||||
|
|
||||||
|
int e[] = { 123, 45, 67, 89, 10, 11, 12, };
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
unsigned char i;
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
for (i = 0; i < 7; ++i) {
|
||||||
|
printf("j: %d expect: %d\n", j[i], e[i]);
|
||||||
|
if (j[i] != e[i]) return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
printf("all fine\n");
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
|
@ -1,6 +0,0 @@
|
||||||
#define hash_hash # ## #
|
|
||||||
#define mkstr(a) # a
|
|
||||||
#define in_between(a) mkstr(a)
|
|
||||||
#define join(c, d) in_between(c hash_hash d)
|
|
||||||
|
|
||||||
char p[] = join(x, y); // Comment
|
|
|
@ -1,3 +0,0 @@
|
||||||
#define t(x,y,z) x ## y ## z
|
|
||||||
int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),
|
|
||||||
t(10,,), t(,11,), t(,,12), t(,,) };
|
|
|
@ -1,3 +0,0 @@
|
||||||
#define t(x,y,z) x ## y ## z
|
|
||||||
int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),
|
|
||||||
t(10,,), t(,11,), t(,,12), t(,,) };
|
|
Loading…
Reference in New Issue
Block a user