• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Baremetal Lisp interpreter and compiler for low-resource devices


Commit MetaInfo

Revision5258c55f53987714c1d7bf68074a3faf7f124106 (tree)
Zeit2020-09-10 10:47:42
AutorAlaskanEmily <emily@alas...>
CommiterAlaskanEmily

Log Message

Add a unit test for struct layout.

Not that it was a problem, but now we know it's not a problem.

Ändern Zusammenfassung

Diff

--- a/test_sl_s.c
+++ b/test_sl_s.c
@@ -20,6 +20,9 @@
2020 #include "sl_s_parse.h"
2121 #include "yyy_test.h"
2222
23+/* Get offsetof */
24+#include <stddef.h>
25+
2326 /* Just for nice housekeeping, keep the other license code in another file. */
2427 #include "test_memcpy.c"
2528
@@ -32,6 +35,34 @@
3235
3336 /*****************************************************************************/
3437
38+#ifndef __VBCC__
39+
40+static int TestLayout(void){
41+ int SUCCESS_INDICATOR = 1;
42+ /* Not really a unit test, this just checks that the layout of the structs
43+ * meets our requirements. */
44+
45+ YYY_EXPECT_INT_EQ(
46+ offsetof(struct SL_S_Ref, ref),
47+ offsetof(struct SL_S_List, ref));
48+ YYY_EXPECT_INT_EQ(
49+ offsetof(struct SL_S_Ref, ref),
50+ offsetof(struct SL_S_Atom, ref));
51+#ifndef SL_S_NO_PARSE_INFO
52+ YYY_EXPECT_INT_EQ(
53+ offsetof(struct SL_S_Line, line),
54+ offsetof(struct SL_S_List, line));
55+ YYY_EXPECT_INT_EQ(
56+ offsetof(struct SL_S_Line, line),
57+ offsetof(struct SL_S_Atom, line));
58+#endif
59+ return SUCCESS_INDICATOR;
60+}
61+
62+#endif
63+
64+/*****************************************************************************/
65+
3566 static int TestLengthEmpty(void){
3667 int SUCCESS_INDICATOR = 1;
3768 YYY_EXPECT_INT_EQ(SL_S_Length(SL_S_NIL), 0);
@@ -216,6 +247,9 @@ static int TestCompareLists1(void){
216247 /*****************************************************************************/
217248
218249 static const struct YYY_Test sl_s_parse_tests[] = {
250+#ifndef __VBCC__
251+ YYY_TEST(TestLayout),
252+#endif
219253 YYY_TEST(TestLengthEmpty),
220254 YYY_TEST(TestLengthOne),
221255 YYY_TEST(TestLengthMany),