History

more tests

bellard committed 24 years ago

Commit f1418e81 parent bc427f51 file · +99 −1Browse files

Unified · Split

tcctest.c+99−1
@@ -57,6 +57,9 @@ void bitfield_test(void); · 56 unmodified lines
5757 void c99_bool_test(void);
5858 void float_test(void);
5959 void longlong_test(void);
60+void stdarg_test(void);
61+void whitespace_test(void);
62+void relocation_test(void);
6063
6164 int fib(int n);
6265 void num(int n);
@@ -101,7 +104,7 @@ int isid(int c); · 38 unmodified lines
101104
102105 void macro_test()
103106 {
104− printf("macro:\n");
107+ printf("macro:\n");
105108 pf("N=%d\n", N);
106109 printf("aaa=%d\n", AAA);
107110
@@ -174,6 +177,10 @@ void macro_test() · 66 unmodified lines
174177
175178 MACRO_NOARGS();
176179
180+#ifdef __LINE__
181+ printf("__LINE__ defined\n");
182+#endif
183+
177184 printf("__LINE__=%d __FILE__=%s\n",
178185 __LINE__, __FILE__);
179186 #line 200
@@ -192,6 +199,9 @@ void macro_test() · 12 unmodified lines
192199 dprintf1(1, "vaarg1\n");
193200 dprintf1(1, "vaarg1=%d\n", 2);
194201 dprintf1(1, "vaarg1=%d %d\n", 1, 2);
202+
203+ /* gcc extension */
204+ printf("func='%s'\n", __FUNCTION__);
195205 }
196206
197207 int op(a,b)
@@ -409,6 +419,9 @@ int main(int argc, char **argv) · 211 unmodified lines
409419 c99_bool_test();
410420 float_test();
411421 longlong_test();
422+ stdarg_test();
423+ whitespace_test();
424+ relocation_test();
412425 return 0;
413426 }
414427
@@ -1362,3 +1375,88 @@ void longlong_test(void) · 947 unmodified lines
13621375 #endif
13631376 }
13641377
1378+void vprintf1(const char *fmt, ...)
1379+{
1380+ va_list ap;
1381+ const char *p;
1382+ int c, i;
1383+ double d;
1384+ long long ll;
1385+
1386+ va_start(ap, fmt);
1387+
1388+ p = fmt;
1389+ for(;;) {
1390+ c = *p;
1391+ if (c == '\0')
1392+ break;
1393+ p++;
1394+ if (c == '%') {
1395+ c = *p;
1396+ switch(c) {
1397+ case '\0':
1398+ goto the_end;
1399+ case 'd':
1400+ i = va_arg(ap, int);
1401+ printf("%d", i);
1402+ break;
1403+ case 'f':
1404+ d = va_arg(ap, double);
1405+ printf("%f", d);
1406+ break;
1407+ case 'l':
1408+ ll = va_arg(ap, long long);
1409+ printf("%Ld", ll);
1410+ break;
1411+ }
1412+ p++;
1413+ } else {
1414+ putchar(c);
1415+ }
1416+ }
1417+ the_end:
1418+ va_end(ap);
1419+}
1420+
1421+
1422+void stdarg_test(void)
1423+{
1424+ vprintf1("%d %d %d\n", 1, 2, 3);
1425+ vprintf1("%f %d %f\n", 1.0, 2, 3.0);
1426+ vprintf1("%l %l %d %f\n", 1234567891234LL, 987654321986LL, 3, 1234.0);
1427+}
1428+
1429+void whitespace_test(void)
1430+{
1431+ char *str;
1432+
1433+ #if 1
1434+ pri\
1435+ntf("whitspace:\n");
1436+#endif
1437+ pf("N=%d\n", 2);
1438+ pri\
1439+ntf("aaa=%d\n", 3);
1440+
1441+ pri\
1442+\
1443+ntf("min=%d\n", 4);
1444+ printf("len1=%d\n", strlen("
1445+"));
1446+ str = "
1447+";
1448+ printf("len1=%d str[0]=%d\n", strlen(str), str[0]);
1449+ printf("len1=%d\n", strlen(" a
1450+"));
1451+}
1452+
1453+int reltab[3] = { 1, 2, 3 };
1454+
1455+int *rel1 = &reltab[1];
1456+int *rel2 = &reltab[2];
1457+
1458+void relocation_test(void)
1459+{
1460+ printf("*rel1=%d\n", *rel1);
1461+ printf("*rel2=%d\n", *rel2);
1462+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t