1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
10 #include "sjme/nvm/descriptor.h"
16 #include "sjme/util.h"
21 * Tests parsing of class names.
25 SJME_TEST_DECLARE(testDescClassName
)
27 sjme_desc_className
* result
;
29 sjme_jint strLen
, strHash
;
31 /* Setup default package. */
33 strLen
= strlen(string
);
34 strHash
= sjme_string_hash(string
);
38 if (!sjme_desc_interpretClassName(test
->pool
,
39 &result
, string
, strLen
) ||
41 return sjme_unit_fail(test
, "Could not interpret class name?");
43 /* Check that it is valid. */
44 sjme_unit_equalI(test
, strHash
, result
->hash
,
46 sjme_unit_isFalse(test
, result
->isField
,
48 sjme_unit_equalI(test
, 0, sjme_desc_compareClassS(result
,
50 "Incorrect binary name?");
52 /* Setup base package. */
53 string
= "Squeak/In/Box";
54 strLen
= strlen(string
);
55 strHash
= sjme_string_hash(string
);
59 if (!sjme_desc_interpretClassName(test
->pool
,
60 &result
, string
, strLen
) ||
62 return sjme_unit_fail(test
, "Could not interpret class name?");
65 sjme_unit_equalI(test
, strHash
, result
->hash
,
67 sjme_unit_isFalse(test
, result
->isField
,
69 sjme_unit_equalI(test
, 0, sjme_desc_compareClassS(result
,
71 "Incorrect binary name?");
75 if (!sjme_desc_interpretClassName(test
->pool
,
76 &result
, string
, strLen
) ||
78 return sjme_unit_fail(test
, "Could not interpret class name?");
81 string
= "[LSqueak/In/Box;";
82 strLen
= strlen(string
);
83 strHash
= sjme_string_hash(string
);
87 if (!sjme_desc_interpretClassName(test
->pool
,
88 &result
, string
, strLen
) ||
90 return sjme_unit_fail(test
, "Could not interpret class name?");
93 sjme_unit_equalI(test
, strHash
, result
->hash
,
95 sjme_unit_isTrue(test
, result
->isField
,
96 "Was a binary name?");
97 sjme_unit_equalI(test
, 0, sjme_desc_compareClassS(result
,
99 "Incorrect field name?");
102 return SJME_TEST_RESULT_PASS
;