The check to see if an item was already on the heap was randomly hitting.
[jitcs.git] / tests / test_fnctypeinfo.cpp
blob1a55c75badb7c6d0af1fbc02091168c1e84cd472
1 #include "jitcs_fnctypeinfo.h"
2 #include "unittest.h"
4 using namespace jitcs;
6 static bool isIntOrPtrInt(FTTypeId id) {
7 return id == FTT_Int || id == FTT_PtrInt;
11 static void test(UnitTest& t) {
12 typedef void (__cdecl *F0)();
13 typedef int (__stdcall *F2)(int, int*);
14 typedef int* (__fastcall *F8)(int, uint, iptr, uptr, char*, const short*,
15 long&, const int&);
16 t.check("GetFTSubType/1", GetFTSubType<F0>::Value == FTS_CDecl);
17 t.check("GetFTSubType/2", GetFTSubType<F2>::Value == FTS_StdCall);
18 t.check("GetFTSubType/3", GetFTSubType<F8>::Value == FTS_FastCall);
20 t.check("GetFTParamCount/1", GetFTParamCount<F0>::Value == 0);
21 t.check("GetFTParamCount/2", GetFTParamCount<F2>::Value == 2);
22 t.check("GetFTParamCount/3", GetFTParamCount<F8>::Value == 8);
24 t.check("GetFTResultId/1", GetFTResultId<F0>::Value == FTT_Void);
25 t.check("GetFTResultId/2", isIntOrPtrInt(GetFTResultId<F2>::Value));
26 t.check("GetFTResultId/3", GetFTResultId<F8>::Value == FTT_Ptr);
28 t.check("GetFTParamId/1", GetFTParamId<F0, 0>::Value == FTT_Void);
29 t.check("GetFTParamId/2", isIntOrPtrInt(GetFTParamId<F2, 0>::Value));
30 t.check("GetFTParamId/3", GetFTParamId<F2, 1>::Value == FTT_Ptr);
31 t.check("GetFTParamId/4", isIntOrPtrInt(GetFTParamId<F8, 0>::Value));
32 t.check("GetFTParamId/5", isIntOrPtrInt(GetFTParamId<F8, 1>::Value));
33 t.check("GetFTParamId/6", isIntOrPtrInt(GetFTParamId<F8, 2>::Value));
34 t.check("GetFTParamId/7", isIntOrPtrInt(GetFTParamId<F8, 3>::Value));
35 t.check("GetFTParamId/8", GetFTParamId<F8, 4>::Value == FTT_Ptr);
36 t.check("GetFTParamId/9", GetFTParamId<F8, 5>::Value == FTT_Ptr);
37 t.check("GetFTParamId/10", GetFTParamId<F8, 6>::Value == FTT_Ptr);
38 t.check("GetFTParamId/11", GetFTParamId<F8, 7>::Value == FTT_Ptr);
41 static UnitTestRun _("FncTypeInfo", test);