Skip to content

Commit

Permalink
#341 Add core testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander Mertens authored and Sander Mertens committed Sep 12, 2015
1 parent ec652e3 commit 06b7250
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 2 deletions.
73 changes: 71 additions & 2 deletions packages/corto/lang/test/src/test_StringDeserializer.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,63 @@ cx_void _test_StringDeserializer_tc_deserCompositeMixed(test_StringDeserializer
/* $end */
}

/* ::test::StringDeserializer::tc_deserCompositeNested() */
cx_void _test_StringDeserializer_tc_deserCompositeNested(test_StringDeserializer this) {
/* $begin(::test::StringDeserializer::tc_deserCompositeNested) */

cx_object o = NULL;
cx_int16 ret = cx_fromStr(&o, "test::Line{{10, 20}, {30, 40}}");
test_assert(o != NULL);
test_assert(ret == 0);
test_assert(cx_typeof(o) == (cx_type)test_Line_o);
test_Line *l = o;
test_assert(l->start.x == 10);
test_assert(l->start.y == 20);
test_assert(l->stop.x == 30);
test_assert(l->stop.y == 40);
cx_delete(o);

/* $end */
}

/* ::test::StringDeserializer::tc_deserCompositeNestedMembers() */
cx_void _test_StringDeserializer_tc_deserCompositeNestedMembers(test_StringDeserializer this) {
/* $begin(::test::StringDeserializer::tc_deserCompositeNestedMembers) */

cx_object o = NULL;
cx_int16 ret = cx_fromStr(&o, "test::Line{stop={y=40, x=30}, start={x=10, y=20}}");
test_assert(o != NULL);
test_assert(ret == 0);
test_assert(cx_typeof(o) == (cx_type)test_Line_o);
test_Line *l = o;
test_assert(l->start.x == 10);
test_assert(l->start.y == 20);
test_assert(l->stop.x == 30);
test_assert(l->stop.y == 40);
cx_delete(o);

/* $end */
}

/* ::test::StringDeserializer::tc_deserCompositeNestedMixed() */
cx_void _test_StringDeserializer_tc_deserCompositeNestedMixed(test_StringDeserializer this) {
/* $begin(::test::StringDeserializer::tc_deserCompositeNestedMixed) */

cx_object o = NULL;
cx_int16 ret = cx_fromStr(&o, "test::Line{start={x=40, 30}, {x=10, 20}}");
test_assert(o != NULL);
test_assert(ret == 0);
test_assert(cx_typeof(o) == (cx_type)test_Line_o);
test_Line *l = o;
test_assert(l->start.x == 10);
test_assert(l->start.y == 20);
test_assert(l->stop.x == 30);
test_assert(l->stop.y == 40);
cx_delete(o);

/* $end */
}

/* ::test::StringDeserializer::tc_deserCompositeNoType() */
cx_void _test_StringDeserializer_tc_deserCompositeNoType(test_StringDeserializer this) {
/* $begin(::test::StringDeserializer::tc_deserCompositeNoType) */
Expand Down Expand Up @@ -709,7 +766,13 @@ cx_void _test_StringDeserializer_tc_deserUint8Overflow(test_StringDeserializer t
cx_void _test_StringDeserializer_tc_errExcessElements(test_StringDeserializer this) {
/* $begin(::test::StringDeserializer::tc_errExcessElements) */

/* << Insert implementation >> */
cx_string err;
cx_object o = NULL;
cx_int16 ret = cx_fromStr(&o, "test::Point{10, 20, 30}");
test_assert(o == NULL);
test_assert(ret != 0);
test_assert((err = cx_lasterr()) != NULL);
test_assert(!strcmp(err, "excess elements"));

/* $end */
}
Expand Down Expand Up @@ -764,7 +827,13 @@ cx_void _test_StringDeserializer_tc_errTypeMismatch(test_StringDeserializer this
cx_void _test_StringDeserializer_tc_errUnresolvedMember(test_StringDeserializer this) {
/* $begin(::test::StringDeserializer::tc_errUnresolvedMember) */

/* << Insert implementation >> */
cx_string err;
cx_object o = NULL;
cx_int16 ret = cx_fromStr(&o, "test::Point{a = 10}");
test_assert(o == NULL);
test_assert(ret != 0);
test_assert((err = cx_lasterr()) != NULL);
test_assert(!strcmp(err, "member 'a' not found"));

/* $end */
}
Expand Down
7 changes: 7 additions & 0 deletions packages/corto/lang/test/test.cx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ struct Point::
struct Point3D: Point::
z: int32

struct Line::
start, stop: Point

// Object management testcases
class ObjectMgmt: test::Suite::
prevAttr: lang::attr, local|private
Expand Down Expand Up @@ -154,3 +157,7 @@ class StringDeserializer: test::Suite::
void tc_deserInheritance() test::Case
void tc_deserInheritanceMembers() test::Case
void tc_deserInheritanceMixed() test::Case

void tc_deserCompositeNested() test::Case
void tc_deserCompositeNestedMembers() test::Case
void tc_deserCompositeNestedMixed() test::Case

0 comments on commit 06b7250

Please sign in to comment.