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 // -------------------------------------------------------------------------*/
15 #include "sjme/util.h"
20 * Tests parsing of class names.
24 SJME_TEST_DECLARE(testDescClassName
)
26 sjme_desc_className
* result
;
28 sjme_jint strLen
, strHash
;
30 /* Setup default package. */
32 strLen
= strlen(string
);
33 strHash
= sjme_string_hash(string
);
37 if (!sjme_desc_interpretClassName(test
->pool
,
38 &result
, string
, strLen
) ||
40 return sjme_unit_fail(test
, "Could not interpret class name?");
42 /* Check that it is valid. */
43 sjme_unit_equalI(test
, strHash
, result
->hash
,
45 sjme_unit_isFalse(test
, result
->isField
,
47 sjme_unit_equalI(test
, 0, sjme_desc_compareClassS(result
,
49 "Incorrect binary name?");
51 /* Setup base package. */
52 string
= "Squeak/In/Box";
53 strLen
= strlen(string
);
54 strHash
= sjme_string_hash(string
);
58 if (!sjme_desc_interpretClassName(test
->pool
,
59 &result
, string
, strLen
) ||
61 return sjme_unit_fail(test
, "Could not interpret class name?");
64 sjme_unit_equalI(test
, strHash
, result
->hash
,
66 sjme_unit_isFalse(test
, result
->isField
,
68 sjme_unit_equalI(test
, 0, sjme_desc_compareClassS(result
,
70 "Incorrect binary name?");
74 if (!sjme_desc_interpretClassName(test
->pool
,
75 &result
, string
, strLen
) ||
77 return sjme_unit_fail(test
, "Could not interpret class name?");
80 string
= "[LSqueak/In/Box;";
81 strLen
= strlen(string
);
82 strHash
= sjme_string_hash(string
);
86 if (!sjme_desc_interpretClassName(test
->pool
,
87 &result
, string
, strLen
) ||
89 return sjme_unit_fail(test
, "Could not interpret class name?");
92 sjme_unit_equalI(test
, strHash
, result
->hash
,
94 sjme_unit_isTrue(test
, result
->isField
,
95 "Was a binary name?");
96 sjme_unit_equalI(test
, 0, sjme_desc_compareClassS(result
,
98 "Incorrect field name?");
101 return SJME_TEST_RESULT_PASS
;