source: git/tests/Singular/test_ipid.cpp @ e4e36c

spielwiese
Last change on this file since e4e36c was 383b2c8, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
CHG: mod2.h should better be included as <kernel/mod2.h>
  • Property mode set to 100644
File size: 2.8 KB
Line 
1#include <iostream>
2#include <sstream>
3
4#include "test_ipid.hpp"
5#include <kernel/mod2.h>
6#include <Singular/ipid.h>
7
8#include "utils.hpp"
9
10using namespace Singular::tests;
11
12CPPUNIT_TEST_SUITE_REGISTRATION( Singular::tests::IpIdTest );
13
14/* To be tested:
15int     iiS2I(const char *s)
16idhdl   enterid(const char * s, int lev, idtyp t, idhdl* root, BOOLEAN init)
17void    killid(const char * id, idhdl * ih)
18void    killhdl(idhdl h, package proot)
19void    killhdl2(idhdl h, idhdl * ih, ring r)
20idhdl   ggetid(const char *n, BOOLEAN local, idhdl *packhdl)
21idhdl   ggetid(const char *n)
22void    ipListFlag(idhdl h)
23lists   ipNameList(idhdl root)
24static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
25void    ipMoveId(idhdl tomove)
26const char * piProcinfo(procinfov pi, const char *request)
27void    piCleanUp(procinfov pi)
28BOOLEAN piKill(procinfov pi)
29void    paCleanUp(package pack)
30char    *idhdl2id(idhdl pck, idhdl h)
31void    iiname2hdl(const char *name, idhdl *pck, idhdl *h)
32idhdl   packFindHdl(package r)
33
34idhdl idrec::get(const char * s, int lev)
35idhdl idrec::set(const char * s, int lev, idtyp t, BOOLEAN init)
36char * idrec::String()
37
38void proclevel::push(char *n)
39void proclevel::pop()
40 */
41
42extern int iiS2I(const char *s);
43
44
45IpIdTest::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
56void IpIdTest::setUp() {
57}
58
59void IpIdTest::tearDown() {
60}
61
62void IpIdTest::test_iiS2I() 
63{
64  const char *s1 = "1233";
65  printf("iiS2I(%s)=%d\n", s1, iiS2I(s1));
66 
67  return;
68}
69
70void 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));
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));
98    //snprintf(s, sizeof(s), "dummy%06d", i);
99    killid(s, &IDROOT);
100    CPPUNIT_ASSERT_EQUAL((idhdl)0, ggetid(s));
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
117void IpIdTest::test_killid() {
118}
119
120void IpIdTest::test_killhdl() {
121}
122
123void IpIdTest::test_ggetid() {
124}
Note: See TracBrowser for help on using the repository browser.