1 | #include <iostream> |
---|
2 | #include <sstream> |
---|
3 | |
---|
4 | #include "test_ipid.hpp" |
---|
5 | #include <Singular/mod2.h> |
---|
6 | #include <Singular/ipid.h> |
---|
7 | |
---|
8 | #include "utils.hpp" |
---|
9 | |
---|
10 | using namespace Singular::tests; |
---|
11 | |
---|
12 | CPPUNIT_TEST_SUITE_REGISTRATION( Singular::tests::IpIdTest ); |
---|
13 | |
---|
14 | /* To be tested: |
---|
15 | int iiS2I(const char *s) |
---|
16 | idhdl enterid(const char * s, int lev, idtyp t, idhdl* root, BOOLEAN init) |
---|
17 | void killid(const char * id, idhdl * ih) |
---|
18 | void killhdl(idhdl h, package proot) |
---|
19 | void killhdl2(idhdl h, idhdl * ih, ring r) |
---|
20 | idhdl ggetid(const char *n, BOOLEAN local, idhdl *packhdl) |
---|
21 | idhdl ggetid(const char *n, BOOLEAN local) |
---|
22 | void ipListFlag(idhdl h) |
---|
23 | lists ipNameList(idhdl root) |
---|
24 | static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2) |
---|
25 | void ipMoveId(idhdl tomove) |
---|
26 | const char * piProcinfo(procinfov pi, const char *request) |
---|
27 | void piCleanUp(procinfov pi) |
---|
28 | BOOLEAN piKill(procinfov pi) |
---|
29 | void paCleanUp(package pack) |
---|
30 | char *idhdl2id(idhdl pck, idhdl h) |
---|
31 | void iiname2hdl(const char *name, idhdl *pck, idhdl *h) |
---|
32 | idhdl packFindHdl(package r) |
---|
33 | |
---|
34 | idhdl idrec::get(const char * s, int lev) |
---|
35 | idhdl idrec::set(const char * s, int lev, idtyp t, BOOLEAN init) |
---|
36 | char * idrec::String() |
---|
37 | |
---|
38 | void proclevel::push(char *n) |
---|
39 | void proclevel::pop() |
---|
40 | */ |
---|
41 | |
---|
42 | extern int iiS2I(const char *s); |
---|
43 | |
---|
44 | |
---|
45 | IpIdTest::IpIdTest() { |
---|
46 | _basePack=(package)omAlloc0(sizeof(*basePack)); |
---|
47 | basePack=_basePack; |
---|
48 | currPack=_basePack; |
---|
49 | idhdl h=enterid("Top", 0, PACKAGE_CMD, &IDROOT, TRUE); |
---|
50 | //enterid("Top", 0, PACKAGE_CMD, &IDROOT, TRUE); |
---|
51 | // IDPACKAGE(h)=basePack; |
---|
52 | currPackHdl=h; |
---|
53 | // basePackHdl=h; |
---|
54 | } |
---|
55 | |
---|
56 | void IpIdTest::setUp() { |
---|
57 | } |
---|
58 | |
---|
59 | void IpIdTest::tearDown() { |
---|
60 | } |
---|
61 | |
---|
62 | void IpIdTest::test_iiS2I() |
---|
63 | { |
---|
64 | const char *s1 = "1233"; |
---|
65 | printf("iiS2I(%s)=%d\n", s1, iiS2I(s1)); |
---|
66 | |
---|
67 | return; |
---|
68 | } |
---|
69 | |
---|
70 | void IpIdTest::test_enterid() { |
---|
71 | double fStart; |
---|
72 | double fEnd; |
---|
73 | |
---|
74 | idhdl start; |
---|
75 | idhdl rh; |
---|
76 | std::cout<<"enterid\n"; |
---|
77 | printf("Base: %p\n", basePack); |
---|
78 | |
---|
79 | std::cout<<"enterid\n"; |
---|
80 | std::cout<<"enterid\n"; |
---|
81 | fStart = Time(); |
---|
82 | int nMax = 10000; |
---|
83 | for(int i=0; i<nMax; i++) { |
---|
84 | char s[64]; |
---|
85 | snprintf(s, sizeof(s), "dummy%06d", i); |
---|
86 | rh = enterid(s, 0, INT_CMD, &IDROOT, TRUE); |
---|
87 | CPPUNIT_ASSERT_EQUAL(rh, ggetid(s, TRUE)); |
---|
88 | } |
---|
89 | fEnd = Time(); |
---|
90 | printf("Find sizeof enterid Time: for %d : %f\n", nMax, fEnd-fStart); |
---|
91 | |
---|
92 | fStart = Time(); |
---|
93 | for(int i=0; i<nMax; i++) { |
---|
94 | char s[64]; |
---|
95 | snprintf(s, sizeof(s), "ZDummy%06d", i); |
---|
96 | rh = enterid(s, 0, INT_CMD, &IDROOT, TRUE); |
---|
97 | CPPUNIT_ASSERT_EQUAL(rh, ggetid(s, TRUE)); |
---|
98 | //snprintf(s, sizeof(s), "dummy%06d", i); |
---|
99 | killid(s, &IDROOT); |
---|
100 | CPPUNIT_ASSERT_EQUAL((idhdl)0, ggetid(s, TRUE)); |
---|
101 | } |
---|
102 | fEnd = Time(); |
---|
103 | printf("Find sizeof enterid and killid Time: for %d : %f\n", nMax, fEnd-fStart); |
---|
104 | |
---|
105 | #if 0 |
---|
106 | idhdl h=IDROOT;//_basePack->idroot; |
---|
107 | start=h; |
---|
108 | while (h!=NULL) |
---|
109 | { |
---|
110 | std::cout<<"Name: "<<h->id<<std::endl; |
---|
111 | |
---|
112 | h = IDNEXT(h); |
---|
113 | } |
---|
114 | #endif |
---|
115 | } |
---|
116 | |
---|
117 | void IpIdTest::test_killid() { |
---|
118 | } |
---|
119 | |
---|
120 | void IpIdTest::test_killhdl() { |
---|
121 | } |
---|
122 | |
---|
123 | void IpIdTest::test_ggetid() { |
---|
124 | } |
---|